#include <bits/stdc++.h>
using namespace std;
const int N = 1000100;
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
  long long res = 0;
  for (int i = 0; i < n / 2; i++) {
    res += (long long)(a[i] + a[n - i - 1]) * (a[i] + a[n - i - 1]);
  }
  cout << res;
}
