favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

# House Robber

You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses are broken into on the same night.

Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.

#### Input

The first number contains the number of the houses n (1n106). Second line contains n integers a1, a2, ..., an, where ai is the amount of money that can be robbed in the i-th house.

#### Output

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

Time limit 3 seconds
Memory limit 128 MiB
Input example #1
5
6 1 2 10 4

Output example #1
16