#include <bits/stdc++.h>
using namespace std;
int M = 998244353;
int main() {
  int n;
  long long sum = 0;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n / 2; i++) {
    sum += (v[i] + v[n - i - 1]) * (v[i] + v[n - i - 1]);
  }
  cout << sum << "\n";
}
