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