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