Oldier array
题号:NC243691
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You now have an array a and you can construct an array b  of any length, where each element is an element that has appeared in array a. The set c  is all possible sums of the array b , find the largest integer which is not in set c.

输入描述:

The first line contains a single integer  which is the size of array a .

The second line contains n integers which is the element of the array a . 

输出描述:

Output a single number - the maximun integer which is not in set c, if the number is infinity, then output -2.
示例1

输入

复制
3
5 8 10

输出

复制
27
示例2

输入

复制
10
2 4 4 6 6 6 8 8 8 8

输出

复制
-2
示例3

输入

复制
3
1 2 3

输出

复制
-1