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