#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int n;
int i, j, k;
int a[300010];
long long ans = 0;
int main() {
  n = read();
  for (i = 1; i <= n; i++) {
    a[i] = read();
    ans += a[i] * a[i];
  }
  sort(a + 1, a + 1 + n);
  for (i = 1; i <= n; i++) {
    ans += a[i] * a[n - i + 1];
  }
  cout << ans << endl;
}
