Recently MINIEYE's engineer M is working on neural network model training and he has found that if the output of the network is S = (S1, S2, …, Sn), then we can use mex(S) to predict the total training time of the neural network. Define mex(S) as:
Here S' ≤ S means S' is a subsequence of S, ∑S' represents the sum of all elements in S'. Please note that S' can be empty, and in that case ∑S' is 0.
M needs your help to calculate mex(S).
The first line contains a single integer n(1 ≤ n ≤ 105).
The second line contains n non-negative integers Si(0 ≤ Si < 231).
Print mex(S) in a single line.