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