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