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