#include <bits/stdc++.h>
using namespace std;
int n, a[10000000], cnt;
long long ans, sum[10000000];
bool vis[10000000];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n / 2; i++) {
    sum[++cnt] += a[n - i + 1] + a[i];
  }
  for (int i = 1; i <= cnt; i++) ans += sum[i] * sum[i];
  cout << ans << endl;
  return 0;
}
