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