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