Mex
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
64bit IO Format: %lld

题目描述

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 = (S1S2, …, 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.
示例1

输入

复制
3
1 2 5

输出

复制
4

说明

S'=(), ∑S'=0

S'=(1), ∑S'=1

S'=(2), ∑S'=2

S'=(1,2), ∑S'=3

S'=(5), ∑S'=5

There
is no way for ∑S'=4, hence 4 is the answer.