#include <bits/stdc++.h>
using namespace std;
int main() {
  iostream::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<unsigned long long> numbers(N);
  for (long long i = 0; i < N; ++i) {
    cin >> numbers[i];
  }
  sort(numbers.begin(), numbers.end());
  int l = 0;
  int r = N - 1;
  unsigned long long result = 0;
  while (l < r) {
    unsigned long long t = numbers[l] + numbers[r];
    result += t * t;
    l += 1;
    r -= 1;
  }
  cout << result << "\n";
  return 0;
}
