#include<bits/stdc++.h>
#define ll long long
using namespace std ;
int main()
{
    ll n , i , j ; cin>>n ;
    ll a[n] ;
    for(i=0;i<n;i++){
        cin>> a[i] ;
    }
    ll stt=0 , st=0 , s=0  ;
    for(i=0;i<n;i++){
        stt+= i*a[i]*a[i] - 2*s* a[i]+st ;
        s+=a[i] ;
        st+= a[i]*a[i] ;
    }
    cout<< stt <<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e5+3;
template <typename T>
inline void read(T &x){
    x=0;char ch=getchar();bool f=false;
    while(!isdigit(ch)) f|=ch=='-',ch=getchar();
    while(isdigit(ch))  x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    x=f?-x:x;
}
template <typename T>
inline void print(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10^48);
}
int n;
ll tong[405];
ll ans;
int main(){
    read(n);
    for(register int i=1;i<=n;++i){
        int tep;read(tep);
        tong[tep+200+1]++;
    }
    for(register int i=1;i<=401;++i){
        for(register int j=i+1;j<=401;++j){
            ll tot=tong[i]*tong[j];
            ans+=tot*(j-i)*(j-i);
        }
    }
    print(ans);
    return 0;
}
