AlgoUniversity
  • Go Back
Discussion
Minimum Books :

Author

Akshay Sharma

Difficulty Level : Easy

Submissions : 156

Asked In : Salesforce

Marks :10

: 2 | : 0

Given N boxes containing a different number of books in each box (numBook[i]), take a minimum number of books from the boxes conditions are such that:

You must take either all or none books inside a given box

Firstly, you cannot skip taking books from boxes adjacent to each other. Box 1 and 2 can not be skipped but you can skip boxes 1 and 3.

Secondly, you cannot take books from boxes adjacent to each other. Box 1 and 2 can not be taken but you can take boxes 1 and 3.

You must have a minimum number of books in your hand.

Input

The first line of each test case contains a single integer N ($$$ 1 \le N \le 100$$$)

The next line contains an array of size N.

Output

For each test case print the minimum number of books

Example

Input
5
1 3 4 2 3
Output
5

Note

For example :

If there are 6 boxes and the number of books in the box are {7,2,13,12,9,1} then the minimum number of books u can take is 15(By skipping box 1,3,5)

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.