#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
ll a[N],b[N];
ll sum = 0;
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
b[i] = a[i] + b[i - 1];
}
sum = a[2] - a[1];
for(int i = 3; i <= n; i++){
sum -= (i - 1) * a[i] - b[i - 1];
}
cout << sum << endl;
return 0;
}
评论区