#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long long int, long long int>& a,
               const pair<long long int, long long int>& b) {
  return (a.second < b.second);
}
long long int mpow(long long int x, long long int y) {
  long long int ans = 1;
  while (y) {
    if (y % 2 != 0)
      ans = (ans % 10000000000000) * (x % 10000000000000) % 10000000000000;
    y /= 2;
    x = ((x % 10000000000000) * (x % 10000000000000)) % 10000000000000;
  }
  return ans;
}
void bfs(long long int a[][1000], long long int visit[], long long int s,
         long long int n) {
  deque<long long int> q;
  q.push_back(s);
  visit[s] = 1;
  while (!q.empty()) {
    long long int x = q.front();
    cout << x << " ";
    q.pop_front();
    for (auto i = 0; i < n; i++) {
      if (visit[i] == 0 && a[x][i] == 1) {
        q.push_back(i);
        visit[i] = 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, i;
  cin >> n;
  long long int a[n];
  long long int c = 0;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n / 2; i++) c += mpow(a[i] + a[n - i - 1], 2);
  cout << c;
  return 0;
}
