#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 300000 + 5;
int n, a[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  sort(a + 1, a + 1 + n);
  long long sum = 0;
  for (int i = 1; i <= n / 2; i++) {
    long long t = a[i] + a[n - i + 1];
    sum += t * t;
  }
  cout << sum << endl;
  return 0;
}
