#include <bits/stdc++.h>
using namespace std;
int a[300005];
unsigned long long ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n / 2; i++) {
    ans += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]) * 1LL;
  }
  cout << ans << endl;
  return 0;
}
