#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, m, k[333000];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> k[i];
  sort(k, k + n);
  for (int i = 0; i < n / 2; i++)
    m += (k[i] + k[n - 1 - i]) * (k[i] + k[n - 1 - i]);
  cout << m << endl;
  return 0;
}
