#include <bits/stdc++.h>
int cmp(const void *a, const void *b) { return (*(int *)a - *(int *)b); }
int main() {
  int n, *a, j, i;
  long long s = 0;
  scanf("%d", &n);
  a = (int *)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  qsort(a, n, sizeof(int), cmp);
  for (i = 0, j = n - 1; i < n / 2; i++, j--)
    s += (a[i] + a[j]) * (a[i] + a[j]);
  printf("%lld\n", s);
  free(a);
  return 0;
}
