#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  long long int sum = 0;
  int i = 0, j = n - 1;
  while (i < j) {
    sum = sum + (long long int)(a[i] + a[j]) * (a[i] + a[j]);
    i++;
    j--;
  }
  printf("%lld", sum);
}
