#include <bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
 
 
int main(){
	int n;
	cin>>n;
	ll sum=0;
	ll ans=0;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<n;i++){
		ans+=(a[i]*a[i])*(n-1);
		sum-=a[i];
		ans-=2*a[i]*sum;
	}
	cout<<ans;

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

int main() {
  ll N;
  cin >> N;
  vector<ll> cnt(401);
  for (ll i = 0; i < N; i++) {
    ll A;
    cin >> A;
    cnt[A + 200]++;
  }
  ll ans = 0;
  for (ll i = 0; i <= 400; i++)
    for (ll j = 0; j < i; j++) ans += (i - j) * (i - j) * cnt[i] * cnt[j];
  cout << ans << endl;
}
