In Berland it is the holiday of equality. In honor of the "holiday" the King decided to equalize the welfare of "all citizens in Berland" by the expense of the State TR Easury.
Totally in Berland There are N citizens, the welfare of each of them are estimated as the integer in AI burles (Burle is th E currency in Berland).
You are are the Royal Treasurer, which needs to count the minimum charges of the The king's Kingdom. The king can only give, he hasn ' t-a power to take away them. Input
The "The" the "contains" (1≤n≤100)-the number of citizens in the kingdom.
The second line contains n integers a1, a2, ..., an, where AI (0≤ai≤106)-the welfare of the i-th citizen. Output
In the only line print the integer s-the minimum number of Burles which are had to spend. Example Input
5
0 1 2 3 4
Output
10
Input
5
1 1 0 1 1
Output
1
Input
3
1 3 1
Output
4
Input
1
12
Output
0
Note
In the ' I example if we add to the ' the ' Citizen 4 Burles, to the second 3, to the third 2 and to the fourth 1, then th E Welfare of all citizens would equal 4.
In the second example it's enough to give one burle to the third.
In the third example it's necessary to give two burles to the "the" and "third citizens to" the welfare of citizen s equal 3.
In the fourth example it are possible to give nothing to everyone because all citizens have.
#include <iostream>
#include <cstdio>
#include <algorithm>
int num[105];
using namespace std;
int main ()
{
int n;
scanf ("%d", &n);
for (int i = 0; i < n; i++)
scanf ("%d", &num[i]);
Sort (num, num + N);
int sum = 0;
for (int i = 0; i < n-1 i++)
sum + = num[n-1]-num[i];
cout << sum << endl;
return 0;
}