#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize "-O3"
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a;
  a.resize(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort((a).begin(), (a).end());
  long long ans = 0;
  for (int i = 0; i < (n); i++) {
    ans += ((a[i] + a[n - 1 - i]) * (a[i] + a[n - 1 - i]));
  }
  cout << ans / 2;
}
