#include <bits/stdc++.h>
using namespace std;
const int INF = 999999;
using P = pair<long long, long long>;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a.begin(), a.end());
  int head = 0, tail = n - 1;
  long long sum = 0;
  while (head < tail) {
    sum += (a[head] + a[tail]) * (a[head] + a[tail]);
    head++;
    tail--;
  }
  cout << sum << endl;
}
