#include <bits/stdc++.h>
using namespace std;
long long N, a[300010];
long long read(long long x = 0) {
  long long c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
void init() {
  long long i;
  N = read();
  for (i = 1; i <= N; i++) a[i] = read();
  sort(a + 1, a + N + 1);
}
void work() {
  long long i, ans = 0;
  for (i = 1; i <= (N >> 1); i++)
    ans += ((a[i] + a[N - i + 1]) * (a[i] + a[N - i + 1]));
  cout << ans;
}
int main() {
  init();
  work();
  return 0;
}
