#C5771. Minimum Number of Operations

    ID: 49457 Type: Default 1000ms 256MiB

Minimum Number of Operations

Minimum Number of Operations

Given an array of n integers, you are allowed to perform the following operation: select any two numbers from the array and replace them with their sum. The objective is to make all the resulting elements equal.

It can be proven that the minimum number of operations required is \(n-1\). In each operation, the number of elements in the array reduces by one until only one element remains, which is trivially equal to itself.

Example: If n = 4 and the array is [1, 2, 3, 4], the answer is 3 since \(4-1=3\) operations are needed.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains a single integer \(n\), the number of elements in the array.
  • The second line contains \(n\) space-separated integers representing the array elements.

outputFormat

Output a single integer to standard output (stdout), the minimum number of operations required to make all elements equal, which is \(n-1\).

## sample
4
1 2 3 4
3

</p>