#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 5;
int s[maxn];
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
  }
  sort(s + 1, s + n + 1);
  for (int i = 1; i <= n / 2; i++) {
    a[i] = s[i] + s[n + 1 - i];
    ans += a[i] * a[i];
  }
  printf("%lld\n", ans);
}
