#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int64_t a[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int64_t n, i, ans = 0;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n / 2; ++i)
    ans += (a[i] + a[n - i - 1]) * (a[i] + a[n - 1 - i]);
  cout << ans;
  return 0;
}
