#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, i, j, sum, k, temp;
  scanf("%llu", &n);
  unsigned long long a[n];
  for (i = 0; i < n; i++) {
    scanf("%llu", &a[i]);
  }
  sum = 0;
  sort(a, a + n);
  k = n / 2;
  for (i = 0; i < k; i++) {
    temp = (a[i] + a[n - 1 - i]);
    sum += (temp * temp);
  }
  printf("%llu\n", sum);
  return 0;
}
