#include <bits/stdc++.h>
long long n, m, ans, a[300005];
long long sqr(long long x) { return x * x; }
int main() {
  scanf("%lld", &n);
  for (register int i = (1); i <= (n); ++i) scanf("%lld", &a[i]);
  std::sort(a + 1, a + n + 1);
  int up = n >> 1;
  for (register int i = (1); i <= (up); ++i) ans += sqr(a[i] + a[n - i + 1]);
  printf("%lld", ans);
  return 0;
}
