#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5;
int a[N];
int p[N];
int c[N];
set<pair<int, int>> r;
int main() {
  ::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(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 / 2; ++i) {
    ans += (0LL + a[i] + a[n - 1 - i]) * (0LL + a[i] + a[n - 1 - i]);
  }
  cout << ans << endl;
  return 0;
}
