#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
using LL = long long;
int main() {
  int n;
  cin >> n;
  vector<LL> ns(n);
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> ns[i];
  }
  std::sort(ns.begin(), ns.end());
  LL tot = 0;
  for (int i = (int)0; i < (int)n / 2; ++i) {
    tot += (ns[i] + ns[n - 1 - i]) * (ns[i] + ns[n - 1 - i]);
  }
  cout << tot << endl;
  return 0;
}
