AlgoUniversity
  • Go Back
Discussion
House Robbery :

Author

Ujjwal Srivastava

Difficulty Level : Easy

Submissions : 736

Asked In : Appdynamics

Marks :10

: 11 | : 1

There are $$$N$$$ houses built in a line, each of which contains some value in it. A thief is going to steal the maximal value of these houses, but he can't steal in two adjacent houses because the owner of the stolen houses will tell his two neighbors left and right sides. The task is to find what is the maximum stolen value.

Input

The first line contains an integer $$$N$$$. The second line contains $$$N$$$ integers $$$Arr_{i}$$$ denoting the value of houses.$$$(1 \le N \le 10^5)$$$$$$(1 \le Arr_{i} \le 10^4).$$$

Output

Output maximum stolen value.

Examples

Input
3
1 2 3
Output
4
Input
4
5 6 3 10
Output
16
Input
1
9139
Output
9139

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.