CSES - Missing Coin Sum | Tổng xu bị thiếu

View as PDF

Points: 1400 (p) Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

You have \(n\) coins with positive integer values. What is the smallest sum you cannot create using a subset of the coins?

Input

  • The first input line has an integer \(n\): the number of coins.
  • The second line has \(n\) integers \(x_1,x_2,\ldots,x_n\): the value of each coin.

Output

  • Print one integer: the smallest coin sum.

Constraints

  • \(1 \leq n \leq 2 \cdot 10^5\)
  • \(1 \leq x_i \leq 10^9\)

Example

Sample input

5  
2 9 1 2 7

Sample output

6


Comments (8)

Most recent
Loading comments...