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