#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ll = long long;
using ld = long double;
const double PI = std::acos(-1);
const ll N = 300005;
long long i, j, k, T, n, d, e, g, w, h, q, x, y, z, cnt, r[N], a[N], b[N];
char c[300005];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (ll i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (!(n & 1))
    for (ll i = 0; i < n / 2; i++)
      cnt += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
  else {
    for (ll i = 0; i < n / 2 - 1; i++)
      cnt += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
    i = n / 2 - 1,
    cnt += (a[i] + a[i + 1] + a[i + 2]) * (a[i] + a[i + 1] + a[i + 2]);
  }
  cout << cnt;
}
