#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  long long res, x, y;
  cin >> n;
  vector<int> arr(n);
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  i = 0;
  j = n - 1;
  x = 0;
  y = 0;
  while (i < j) {
    x += arr[j];
    y += arr[i];
    i += 1;
    j -= 1;
  }
  if (i == j) x += arr[j];
  res = x * x + y * y;
  cout << res << endl;
  return 0;
}
