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