#include<bits/stdc++.h>

typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int mod = 998244353;
void solve() {
  int n; cin >> n;
  vector<ll> a(n), sum1(n), sum2(n);  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (!i) {
      sum1[i] = a[i];
      sum2[i] = a[i] * a[i];
    } else {
      sum1[i] = sum1[i - 1] + a[i];
      sum2[i] = sum2[i - 1] + a[i] * a[i];
    }
  }
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += i * a[i] * a[i] - 2  * a[i] * (sum1[i - 1]) + sum2[i - 1]; 
    //cout << ans << '\n';
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0),  cout.tie(0);
  int T = 1; //cin >> T;
  while(T--) {
    solve();
  }
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, start, n) for (int i = start; i < (n); i++)
using ll = long long;

int main()
{
    int N;
    cin >> N;

    vector<ll> A(N);
    ll st1, st2, st3;
    ll sum1 = 0; // sum(A)
    ll sum2 = 0; // sum(A^2)
    rep(i,0,N) 
    {
        cin >> A.at(i);
        sum1 += A.at(i);
        sum2 += A.at(i)*A.at(i);
    }
    ll ans = 0;
    ans = N*sum2 - sum1*sum1;
    cout << ans << endl;
    
    return 0;
}