#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
int a[300005];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long res = 0;
  for (int i = 0, j = n - 1; i < n / 2; j--, i++)
    res += ((a[i] + a[j]) * (a[i] + a[j]));
  cout << res << endl;
  return 0;
}
