#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<long long> segments;
  for (int i = 0; i < n; i++) {
    long long ele;
    cin >> ele;
    segments.push_back(ele);
  }
  sort(segments.begin(), segments.end());
  vector<long long>::iterator middle;
  if (n % 2) {
    middle = segments.end() - segments.size() / 2 - 1;
  } else {
    middle = segments.end() - segments.size() / 2;
  }
  long long v1 = accumulate(segments.begin(), middle, 0);
  long long v2 = accumulate(middle, segments.end(), 0);
  cout << v1 * v1 + v2 * v2 << endl;
  return 0;
}
