#include <bits/stdc++.h>
using namespace std;

int main(){
  long long n, a, b, d;
  cin >> n;
  vector<long long> c(n);
  a = 0;
  d = 0;
  for(int i = 0; i < n; i++){
    cin >> c[i];
    a += c[i];
    d += c[i]*c[i];
  }
  b = (a*a - d);
  cout << (n-1) * d - b << endl;
}
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
    long long int n, ans = 0; cin >> n;
    vector<long long int> a(n, 0);
    unordered_map<long long int, long long int> Map;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        Map[a[i]]++;
    }
    for (int i = -200; i <= 200; i++) {
        for (int j = i + 1; j <= 200; j++) {
            ans += Map[i] * Map[j] * (abs(i - j) * abs(i - j));
        }
    }
    cout << ans << endl;
}
