#include <iostream>
#include <algorithm>
using namespace std;
int ans, mini = 0x7f7f7f7f;
int n, arr[55];
int main(){
cin >> n;
for (int i=1; i<=n; i++){
cin >> arr[i];
mini = min(mini, arr[i]);
}
for (int i=1; i<=n; i++){
ans += arr[i] - mini;
}
cout << ans << endl;
return 0;
}