#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = int(0); i <= int(n - 1); i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long answ = 0ll;
  for (int i = int(0); i <= int(n / 2 - 1); i++) {
    answ += ((long long)a[i] + (long long)a[n - i - 1]) * 1ll *
            ((long long)a[i] + (long long)a[n - i - 1]);
  }
  cout << answ << '\n';
  return 0;
}
