// Problem: C - Squared Error
// Contest: AtCoder - AtCoder Beginner Contest 194
// URL: https://atcoder.jp/contests/abc194/tasks/abc194_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Parsed on: 10-03-2021 21:39:49 IST (UTC+05:30)
// Author: Kapil Choudhary
// ********************************************************************
// कर्मण्येवाधिकारस्ते मा फलेषु कदाचन |
// मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि || १.४७ ||
// ********************************************************************

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi> vvi;
typedef vector<vll>	vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;

void solve()
{
  	int n; cin >> n;
  	vi cnt(401, 0);
  	for(int i = 0; i < n; i++) {
  		int x; cin >> x;
  		x += 200;
  		cnt[x]++;
  	}
  	
  	ll res = 0LL;
  	for(int i = 0; i <= 400; i++) {
  		for(int j = i + 1; j <= 400; j++) {
  			res += (ll)cnt[i] * cnt[j] * (i - j) * (i - j);
  		}
  	}
  	
  	cout << res << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const ll INF=0x3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m,q;
ll arr[N];
ll dp[N];
ll sq[N];

int main(){
	ll ans = 0;
	cin >> n;
	sq[0] = 0;
	for(ll i = 1; i <= n; i ++ ){
		scanf("%lld",arr + i);
		sq[i] = sq[i - 1] + arr[i] * arr[i];
	}
	dp[n + 1] = 0;
	for(ll i = n; i >= 1; i --){
		dp[i] = dp[i + 1] + arr[i];
	}
	for(ll i = 1; i <= n; i ++ ){
		ans = ans + sq[n] - sq[i];
		ans = ans + (n - i) * arr[i] * arr[i];
		ans = ans - 2 * arr[i] * (dp[i + 1]); 
	}
	cout << ans << endl;
	




	return 0;
}


