// 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

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

using l = long;
using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vl = vector<long>;
using vll = vector<ll>;

#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define modinv(a,m) modEx(a,m-2,m)
#define moddiv(a,b,m) (a*modinv(b,m))%m
const ll mod=1e9+7;

/* These template codes have been taken from cp-algorithms */
ll extEuclid(ll a,ll b,ll& x,ll& y){
	if(b==0){
		x=1;
		y=0;
		return a;
	}
	
	ll x1,y1;
	ll d=extEuclid(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return d;
}

ll modInverse(ll a,ll n){
	ll x,y;
	extEuclid(a,n,x,y);
	return x;
}

ll linearCong(ll a,ll b,ll n){
	ll d=__gcd(a,n);
	
	if(b%d)
		return -1;
	a/=d;b/=d;n/=d;
	ll a_inv=modInverse(a,n);
	ll ans=(b*a_inv)%n;
	if(ans<0)
		ans+=n;
	return ans;
}

void divisors(map<int,int>& d,ll N){
	for(int div : {2,3,5}){
		int cnt=0;
		if(N%div==0){
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
	}
	static array<int,8> increments = {4,2,4,2,4,6,2,6};
	int i=0;
	for(ll div=7;div*div<=N;div+=increments[i++]){
		if((N%div)==0){
			int cnt=0;
			while((N%div)==0){
				N/=div;
				cnt++;
			}
			d[div]=cnt;
		}
		if(i==8)
			i=0;
	}
	if(N>1)
		d[N]=1;
}

/* Print the string of digits without leading zero */
void norm(string& str){
	bool zero=true;
	
	for(auto& c:str){
		if(c!='0')
			zero=false;
		if(c!='0' || !zero)
			cout<<c;
	}
}

void input(vll& v,int N){
	for(int i=0;i<N;i++){
		cin>>v[i];
	}
	sort(all(v));
}

void solve(vll& v,int N){
	ll ans=0;
	
	vll prefix(N);
	prefix[0]=v[0];
	for(int i=1;i<N;i++){
		prefix[i]+=prefix[i-1]+v[i];
	}
	
	for(int i=1;i<N;i++){
		ans-=(prefix[i-1])*v[i];
	}
	ans*=2;

	for(int i=0;i<N;i++)
		ans+=(N-1)*1ll*(v[i]*v[i]);
	
	cout<<ans<<"\n";
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	
	int N;
	cin>>N;
	vll v(N);
	input(v,N);
	solve(v,N);
	
	
	return 0;	
}

#include <bits/stdc++.h>
//#define IHAVEGIRLFRIEND
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,sse4,ssse3,popcnt,abm,mmx,avx,avx2,tune=native")
#define PB emplace_back
#define MP make_pair
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define F first
#define S second
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define REPP(i,a,b) for(int i = a; i <= b; ++i)
#define RREP(i,a,b) for(int i = a; i >= b; --i)
#define endl cout<<'\n'
#define _ <<' '<<
#define CASET int ___T; cin >> ___T; for(int kase = 1; kase <= T; kase++)
#define MS(X,V) memset(X,V,sizeof(X))

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#ifdef IHAVEGIRLFRIEND
#define IOS
#define PAUSE system("pause")
#define debug(...) fprintf(stderr, "\033[1m\033[31m%s [%d] \033[0m(%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__), _do(__VA_ARGS__)
template<typename T> void _do(T &&x){ cerr<<x<<'\n'; }
template<typename T, typename ...S> void _do(T &&x, S &&...y){ cerr<<x<<", ";_do(y...); }
#else
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PAUSE
#define debug(...)
#endif

constexpr int maxn = 3e5 + 5;

ll arr[maxn];

void solve(){
	int N; cin >> N;
	ll ans = 0, sum = 0;	
	REP(i,0,N){
		cin >> arr[i];
		ans += (N-1)*arr[i]*arr[i];
		sum += arr[i];
	}
	REP(i,0,N-1){
		sum -= arr[i];
		ans -= arr[i] * sum * 2; 
	}
	cout << ans << '\n';
}

signed main(){
	IOS;
	solve();
}
