#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  vector<long long> v;
  long long cnt = 0;
  for (long long i = 0, j = n - 1; i < n && j >= 0 && i <= j; i++, j--) {
    v.push_back(a[i] + a[j]);
  }
  for (auto it : v) {
    cnt += (it * it);
  }
  cout << cnt;
  return 0;
}
