Advertisement
NE_SHALY

Untitled

Feb 8th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. n = int(input());
  2. A = list(map(int, input().split()));
  3. res = -1;
  4. sum = 0;
  5. for q in range(n):
  6.     if A[q] <= sum + 1:
  7.         sum = sum + A[q];
  8.     else:
  9.         res = sum + 1;
  10.         break;
  11. if res == -1:
  12.     res = sum + 1;
  13. print(res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement