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