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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll tmp1=0, tmp2=0;
  for(ll i=0; i<n; i++){
    cin >> a[i];
    tmp1 += a[i];
    tmp2 += a[i]*a[i];
  }
  ll ans;
  ans = n*tmp2 - tmp1*tmp1;
  cout << ans << endl;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n;
	cin >> n;
	// std::vector<int> vect(n);
	std::vector<int> v(401,0);
	long long int temp;
	for (int i = 0; i < n; ++i)
	{
		// cin >> vect[i];
		cin >> temp;		
		v[temp+200]++;		
	}
	long long int res = 0;
	for (int i = 1; i < 401; ++i)
	{
		for (int j = 0; j < i; ++j)
		{
			temp = i-j;
			res += (temp * temp) * v[i] * v[j];
		}
	}
	cout << res << endl;
	return 0;
}