#include <bits/stdc++.h>
#define lc (o<<1)
#define rc ((o<<1)|1)
#define PB push_back
#define MK make_pair
using namespace std;
#define DebugP(x) cout << "Line" << __LINE__ << " " << #x << "=" << x << endl

const int maxn = 3e5 + 5;
const int modu = 998244353; // 1e9 + 7
const int inf = 0x3f3f3f3f;
const double eps = 1e-5;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

typedef long long LL;

void read(LL &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch<'0'||ch>'9')  {f|=(ch=='-');ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    x=f?-x:x;
    return;
}

void read(int &x) { LL y; read(y); x = (int)y; }
void read(char &ch) { char s[3]; scanf("%s", s); ch = s[0]; }
void read(char *s) { scanf("%s", s); }
template<class T, class ...U> void read(T &x, U& ... u) { read(x); read(u...); }

int n;
LL a[maxn], sum, sum2, ans;

int main() {
    // freopen("my.txt", "w", stdout);
    read(n);
    for (int i = 0; i < n; ++i) read(a[i]);
    sum = a[0];
    sum2 = a[0]*a[0];
    ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += i*a[i]*a[i] - 2*sum*a[i] + sum2;
        sum += a[i];
        sum2 += a[i]*a[i];
    }
    cout << ans << "\n";
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long N;
  cin >> N;

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  vector<long long> count(401);
  for (int i = 0; i < N; i++) {
    count.at(A.at(i) + 200)++;
  }

  long long total = 0;

  for (int i = 0; i < 401; i++) {
    for (int j = i; j < 401; j++) {
      int x = i - j;
      total += count.at(i) * count.at(j) * x * x;
    }
  }

  cout << total << endl;
}