#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long maxn = 3e5 + 10, inf = 4e18, mod = 1e9 + 7;
const long double pi = 3.14159265359, eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, a[maxn];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long jj = 0;
  for (int i = 0; i < n / 2; i++)
    jj += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
  cout << jj;
  return 0;
}
