#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 50;
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  sort(a.begin(), a.end());
  for (long long i = 0, j = n - 1; i < j; i++, j--) {
    ans += (a[i] + a[j]) * (a[i] + a[j]);
  }
  cout << ans;
}
