#include <bits/stdc++.h>
long long int fastexp(long long int a, long long int n) {
  if (n == 0) {
    return 1;
  }
  long long int r = fastexp(a, n / 2);
  if (n % 2 == 0) {
    return (r * r);
  } else {
    return (r * a * r);
  }
}
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long int count = 0;
  if (n % 2 == 0) {
    for (long long int i = 0; i < n / 2; i++) {
      count = count + fastexp(a[i] + a[n - i - 1], 2);
    }
    cout << count << '\n';
  } else {
    for (long long int i = 0; i < n / 2; i++) {
      if (i == n / 2 - 1) {
        count = count + fastexp(a[i] + a[n - i - 1] + a[i + 1], 2);
        continue;
      }
      count = count + pow(a[i] + a[n - i - 1], 2);
    }
    cout << count << '\n';
  }
}
