#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int main();
void file() {}
void time() {}
const int INF = 1e9 + 99;
using ll = long long int;
using pii = pair<int, int>;
using vec = vector<int>;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  ll n;
  cin >> n;
  vector<ll> v(n);
  for (ll& x : v) {
    cin >> x;
  }
  sort(v.begin(), v.end());
  ll i = 0, j = n - 1;
  ll x = 0, y = 0;
  bool ok = false;
  while (i <= j) {
    if (ok) {
      x += v[i];
      i++;
    } else {
      y += v[j];
      j--;
    }
    ok ^= 1;
  }
  ll ans = x * x + y * y;
  cout << ans << endl;
  return 0;
}
