Compose a polygon
Very easy
Execution time limit is 4 seconds
Runtime memory usage limit is 64 megabytes
Given a set of line segments, determine the minimum number of segments that must be removed so that the remaining segments can form a polygon with non-zero area.
Input
The first line of the input contains an integer n (3 ≤ n ≤ 50), representing the number of segments in the set. The second line lists the lengths of these segments as a sequence of n integers, each between 1 and 10^6 inclusive.
Output
Output the minimum number of segments that need to be removed so that the remaining segments can form a polygon. If no subset of segments can form a polygon, output -1.
Examples
Input #1
Answer #1
Submissions 350
Acceptance rate 24%