#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, k, z, q, r, a[350000];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n / 2; ++i) {
    k += (a[i] + a[n - 1 - i]) * (a[i] + a[n - 1 - i]);
  }
  cout << k;
}
