#include <bits/stdc++.h>
using namespace std;
int v[3 * 100001];
int main() {
  int n;
  long long s = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  sort(v + 1, v + n + 1);
  for (int i = 1; i <= n / 2; ++i) {
    s += (v[i] + v[n - i + 1]) * (v[i] + v[n - i + 1]);
  }
  cout << s;
  return 0;
}
