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