#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-18;
const long double PI = 3.141592653589793238;
;
int n;
long long ar[int(5e5) + 10], ans;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%lld", ar + i);
  }
  sort(ar, ar + n);
  for (int i = 0; i < n / 2; i++) {
    ans += (ar[i] + ar[n - i - 1]) * (ar[i] + ar[n - i - 1]);
  }
  cout << ans << endl;
}
