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