#include<iostream>
#include<utility>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define forn(i, x, n) for(int i = x; i < n; i++)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const bool DEBUG = 0;

void solve(){
    int n;
    cin>>n;
    int a[n];
    forn(i, 0, n) cin>>a[i], a[i] += 200;
    vector<int> f(401);
    forn(i, 0, n) f[a[i]]++;
    ll ans = 0;
    forn(i, 1, f.size()){
        forn(j, 0, i){
            ans += (i - j) * 1ll * (i - j) * f[i] * f[j];
        }
    }
    cout<< ans;

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
    //cin>>t;
	//while(t--) cout<<solve()<<'\n';
	while(t--) solve(), cout<<'\n';


}

#include <bits/stdc++.h>
typedef long long 		ll;
typedef long double 		ld;
#define endl 			"\n"
#define fi 			first
#define se 			second
#define Alkborough 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

const ll MOD = 1e9 + 7;
const ll INF = 2e18;
const ll MAX = 5e4 + 3;

int main(){

//cout<<fixed<<setprecision(15);

Alkborough
   int tc = 1; //cin>>tc;
    while(tc--){
        ll n; cin>>n;
        ll a[n]; for(int i = 0; i < n; i++)cin>>a[i];

        ll ans = 0;
        vector<ll> suf(n+1);
        for(int i = n-1; i >= 0; i--){
            suf[i] = suf[i+1] + a[i];
        }

        for(int i = 0; i < n; i++){
            ans += (n-1)*a[i]*a[i] - 2*a[i]*(suf[i+1]);
        }
        cout<<ans;
    }
return 0;
}
