#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
int a[300007];
long long ans;
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= (n >> 1); ++i) {
    int o = a[i] + a[n - i + 1];
    ans += o * o;
  }
  printf("%I64d\n", ans);
  return 0;
}
