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