#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ub upper_bound
#define lb lower_bound
const int M=1e9L+7;
const ll k=1e12L+7;
const ll MM=1e18L;
unordered_set<ll>s;
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll n;
   cin>>n;
   ll ans=0,a=0;
   for(ll i=0;i<n;++i){
   	ll k;
   	cin>>k;
   	ans+=k*k;
   	a+=k;
   }
   cout<<n*ans-a*a<<"\n";
   return 0;
}
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <complex>
#define ll long long
#define inf 1e9 + 8
#define sinf 1e17 + 500
#define ld long double
#define ull unsigned long long
#define poll complex<double>
#define line pair<poll, poll>
#define pi acos(-1)
#define lp(a, b, c, d) for (ll a = b; a < c; a += d)
#define endl '\n'
//#define EPS 1e-12
#define IO                          \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);                    \
  cout.tie(NULL);                   \
  // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define mod 1000000007
using namespace std;
const ll N = 1e4  +6, SEG = (1 << 14);
ll gcd(ll a, ll b)
{
  if(b==0)return a;
  return gcd(b,a%b);
}
int  main()
{
  IO
 ll n;
 cin>>n;
 ll arr[n];
 map<ll,ll>cnt;
 set<ll>st;
 for(ll i=0;i<n;i++)
 {
   cin>>arr[i];
   cnt[arr[i]]++;
   st.insert(arr[i]);
 }
 vector<ll>v;
 for(auto d:st)
 {
   v.push_back(d);
  // cout<<d<<endl;
 }
 ll res=0;
 for(ll i=0;i<v.size();i++)
 {
   ll tmp=0;
   for(ll j=i+1;j<v.size();j++)
   {
     tmp+=(v[j]-v[i])*(v[j]-v[i])*cnt[v[j]];
   }
   res+=tmp*cnt[v[i]];
 }
 cout<<res<<endl;

  return 0;
}