815. House Robber

0

Easy

As a professional robber, your goal is to rob houses along a street without triggering the security systems. Each house contains a certain amount of money. However, adjacent houses have security systems that will alert the police if two adjacent houses are robbed on the same night. Given an integer array nums representing the amount of money in each house, your task is to determine the maximum amount of money you can rob tonight without alerting the police.

Input Format

The first line of input should contain an integer N, representing the size of the array.
The second line should contain N space-separated integers, describing the money in each house.

Output Format

Print the maximum amount of money you can rob tonight without alerting the police.

Example

Input

5 2 7 9 3 1

Output

12

Constraints

1 <= nums.length <= 100
0 <= nums[i] <= 400
Loading...

View Submissions

Console