#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7fffffff;
const int MAXN = 3e5 + 3;
long long ans;
int n, a[MAXN];
int main() {
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 0; i < (int)(n / 2); i++) {
    ans += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
  }
  cout << ans;
  return 0;
}
