Question: Task: Sums Language: C++ Preferred. (Java, Python is okay as well. - Just need something to follow along while writing the program.) Write a program

Task: Sums Language: C++ Preferred. (Java, Python is okay as well. - Just need something to follow along while writing the program.)

Write a program that inputs a sequence of N integers and finds out the smallest positive integer that cannot be presented as a sum of the elements of any subsequence (consisting of one or more elements, not necessarily consecutive) of the given sequence.

Input: On the first line, a value of N is written. On the second line, the elements of the given sequence are written, separated by spaces.

Output: One integer equals to the requested value.

Constraints:

1 < N < 1000; all the elements of the given sequence are integers in a range from 1000 to 1000.

Example:

Input

5 1 -2 0 7 7

Output

2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!