Smallest sum no subsequence can make
Time limit2sMemory limit512 MB
Given N ≤ 20 numbers, find the smallest natural number that is not the sum of any non-empty subsequence.
- Level
Medium5 of 10
- Topics
- Backtracking, Brute force, Sorting
- Solved
- No attempts yet
Problem
You are given a sequence . Write a program that finds the smallest natural number that cannot be written as the sum of a non-empty subsequence of .
For example, if , you can make , , , , , , and . No subsequence sums to , so the answer is .
Input
The first line contains the size of the sequence ().
The second line contains the elements of , separated by spaces. Each element is a natural number no greater than 100,000.
Output
Print the smallest natural number that is not the sum of any subsequence of .