860. Equalizing Array Elements

0

Medium

Om has given Satyam an array of N integers. He wants to know the minimum number of operations required to make all the elements of the array equal. In a single operation, Satyam can increment N-1 elements of the array by 1. Can you help Satyam find the minimum number of operations?

Input Format

The first line contains a single integer N, which represents the size of the array. The second line contains N space-separated integers that represent the elements of the array.

Output Format

Print the minimum number of moves required to make all the elements of the array equal using the given operation.

Example

Input

3 1 2 3

Output

3

Constraints

1<=N<=10^5 10^-9<=A[i]<=10^9
Loading...

View Submissions

Console