Jump Out
Practice
3.1 (50 votes)
Easy
Problem
85% Success 9021 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You have a field of N boosters. The power of ith booster is given as Ai. If you stand on ith booster, you will get the power Ai and you can make a jump of length Ai. That is, if you are standing on 3rd booster and it's power is 5, then you will land on position 8. Currently, you are standing outside the field to the left of first booster and you want to across this field by reaching to the right of Nth booster. You want to make only one jump to any booster such that you will finally land to right of Nth booster. Print the minimum length of initial jump you should make such that you will finally land outside the field by using exactly one booster.

INPUT:
First line of input consists of integer N. Next line consists of N integers A1, A2...AN.

OUTPUT:
Output the minimum length of jump you should make such that you will finally land outside the field using exactly 1 booster.

CONSTRAINTS:
1 ≤ N ≤ 104
1 ≤ Ai ≤ 104

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
72 votes
Tags:
ApprovedBasic ProgrammingEasy
Points:20
48 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyHiringImplementation
Points:20
264 votes
Tags:
ApprovedBasic ProgrammingEasyOpen