#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  long long sum = 0, total = 0;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (i = 0; i < n / 2; i++) {
    sum = a[i] + a[n - 1 - i];
    sum = sum * sum;
    total += sum;
  }
  cout << total << endl;
  return 0;
}
