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