#include <bits/stdc++.h>
using namespace std;
long long modulo(long long num, long long MOD = 1000000007) {
  return ((num % MOD) + MOD) % MOD;
}
long long power(long long b, long long e, long long MOD = 1000000007) {
  long long ans = 1;
  while (e) {
    if (e % 2) ans = (ans * b) % MOD;
    b = (b * b) % MOD;
    e /= 2;
  }
  return ans;
}
long long inv(long long num, long long MOD = 1000000007) {
  return power(modulo(num), MOD - 2, MOD);
}
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  if (n == 2 || n == 3) {
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      ans += a[i];
    }
    ans *= ans;
    cout << ans;
    return;
  }
  sort(a, a + n);
  long long ans = 0;
  for (long long i = 0; i < n / 2; i++) {
    ans += (a[i] + a[n - 1 - i]) * (a[i] + a[n - 1 - i]);
  }
  cout << ans;
}
signed main() { solve(); }
