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