#include <bits/stdc++.h>
using namespace std;
namespace chu_xuan {
void swap(int &a, int &b) {
  register int tmp = a;
  a = b, b = tmp;
}
void read(long long &a) {
  a = 0;
  int b = 1, c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + c - 48, c = getchar();
  a *= b;
}
int In() {
  int a = 0, b = 1, c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') b = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + c - 48, c = getchar();
  return a * b;
}
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a > b ? b : a; }
}  // namespace chu_xuan
using namespace chu_xuan;
const int N = 3e5;
long long n, a[N];
long long ans;
int main() {
  read(n);
  for (int i = 0; i < n; i++) read(a[i]);
  sort(a, a + n);
  for (int i = 0; i < n / 2; i++) {
    ans += (a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
  }
  cout << ans;
  return 0;
}
