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