#C5698. Smallest Non-Representable Sum
Smallest Non-Representable Sum
Smallest Non-Representable Sum
You are given a list of N coin values. Your task is to determine the smallest sum of money that cannot be formed using any subset of these coins. Formally, if the coins (after sorting) are \(V_1, V_2, \ldots, V_N\), then let \(s\) be the smallest sum that you cannot construct. Initially, \(s = 1\). For each coin \(V_i\): if \(V_i > s\), then \(s\) is the answer; otherwise, update \(s = s + V_i\).
inputFormat
The first line contains a single integer N representing the number of coins. The second line contains N space-separated integers denoting the coin values.
outputFormat
Output a single integer which is the smallest sum that cannot be represented using any subset of the given coins.
## sample5
1 1 3 4 6
16