#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
#define CHECK(a) cout << #a << " " << a << endl;
#define CHECK_VEC(V) REP (i, 0, V.size()) cout << i << " " << V[i] << endl;
const int INF = 1e9;
const ll MOD = (ll)1e9 + 7LL;
const vector<int> dx = {0, 1, 0, -1, 0, 1, -1, 1, -1};
const vector<int> dy = {0, 0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool CHMIN(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool CHMAX(T& a, T b){ if (a < b){ a = b; return true; } return false; }

bool comp (pair<string, int> a, pair<string, int> b) {
    if (a.second != b.second) return a.second > b.second;
    else return a.first > b.first;
}

void Main () {
    int N;
    cin >> N;
    vector<pair<string, int>> M (N);
    REP (i, 0, N) cin >> M[i].first >> M[i].second;
    sort(ALL(M), comp);
    cout << M[1].first << endl;
}

int main () {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    //int n; cin >> n; while(n--)
    Main();
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;++i)

int main(){
  long long n,a,s=0,ans=0;
  cin>>n;
  rep(i,n){
    cin>>a;
    ans+=a*a*n;
    s+=a;
  }
  ans-=s*s;
  cout<<ans<<endl;
  return 0;
}