#include <bits/stdc++.h>
int main(void) {
  int N, i, *d;
  long long sum = 0;
  scanf("%d", &N);
  d = (int*)calloc(N, sizeof(int));
  for (i = 0; i < N; i++) scanf("%d", &d[i]);
  std::sort(d, d + N);
  for (i = 0; i < N / 2; i++)
    sum += (d[i] + d[N - i - 1]) * (d[i] + d[N - i - 1]);
  free(d);
  printf("%I64d\n", sum);
  return 0;
}
