版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/polanwind/article/details/84169751
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <math.h>
#include <string>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int ans = 0;
int maxn = -1;
for (int i = 1;i <= n;++i) {
int a;
scanf("%d", &a);
ans += a;
if (a > maxn) {
maxn = a;
}
}
printf("%d\n", (n - 1)*maxn - (ans - maxn));
//system("pause");
return 0;
}