#C3046. Minimum Operations to Reduce Array
Minimum Operations to Reduce Array
Minimum Operations to Reduce Array
Nisha has an integer array of length N. In one operation, she selects any two elements from the array, removes them, and inserts their sum back into the array. This process is repeated until only one element remains. Since each operation decreases the number of elements by 1, the minimum number of operations required is given by the formula \(N-1\).
Your task is to compute this number given the array.
inputFormat
The input is read from stdin and consists of two lines. The first line contains a single integer (N), which denotes the number of elements in the array. The second line contains (N) space-separated integers representing the elements of the array.
outputFormat
Output a single integer to stdout, which is the minimum number of operations required to reduce the array to one element.## sample
4
3 1 4 1
3