The smallest number
Easy
Execution time limit is 1 second
Runtime memory usage limit is 32 megabytes
Given a sorted list of natural numbers (A[1] < ...< A[N]).
Your task is to find the smallest natural number that cannot be expressed as the sum of any subset of numbers from this list. You may use each number from the list at most once, and the sum can be composed of just one number.
Input
The first line contains a single integer (N) ((1 N 10^6))—the number of elements in the list. The second line contains the elements of the list, separated by spaces. All elements are distinct natural numbers, sorted in increasing order, and each does not exceed (10^6).
The input data is guaranteed to be correct.
Output
Output a single integer—the smallest natural number that cannot be formed as described.
Examples
Input #1
Answer #1
Submissions 316
Acceptance rate 23%