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