#include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n) 
using ll = long long;
using ull = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1e9 + 7;

ll modpow(ll x, ll n)
{
  if (n == 0)
    return 1;
  ll res = modpow(x, n / 2);
  if (n % 2 == 0)
    return res * res % mod;
  else
    return res * res % mod * x % mod;
}
   
int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
long long GCD(long long a, long long b)
{
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
using namespace std;

int main() {
  int n; cin >> n;
  ll sum = 0, sum_squ = 0; 
  rep(i, n) {
    ll a; cin >> a;
    sum += a;
    a *= a;
    sum_squ += a;
  }
  ll res = n*sum_squ - sum*sum;
  cout << res << endl;
}
#include "bits/stdc++.h"
using namespace std;

#define dbg(x)      cout << #x << " is " << x << endl
#define all(x)      x.begin(), x.end()
#define pb          push_back
#define sz(x)       (int)(x.size())
#define ll          long long
#define fi          first
#define se          second

const int MOD = 1e9 + 7;
const double eps = 1e-10;
const long long INF = 1e18;
const int N = 2e5 + 10;


void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	ll ans = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
		ans += v[i] * v[i];
	}

	ans *= n;
	ans -= (sum * sum);
	cout << ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}