#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll n,x = 0,y,t = 0,mid,ans; cin >> n;
vector<ll> s(n);
for(ll i=0;i<n;i++){
cin >> s[i];
t += s[i];
}
sort(s.begin(),s.end(),greater<>());
mid = (n+1)/2;
for(ll i=0;i<mid;i++) x += s[i];
y = t-x;
ans = x*x + y*y;
cout << ans;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCl7CglsbCBuLHggPSAwLHksdCA9IDAsbWlkLGFuczsJY2luID4+IG47Cgl2ZWN0b3I8bGw+IHMobik7Cglmb3IobGwgaT0wO2k8bjtpKyspewoJCWNpbiA+PiBzW2ldOwoJCXQgKz0gc1tpXTsKCX0JCglzb3J0KHMuYmVnaW4oKSxzLmVuZCgpLGdyZWF0ZXI8PigpKTsKCW1pZCA9IChuKzEpLzI7Cglmb3IobGwgaT0wO2k8bWlkO2krKykJeCArPSBzW2ldOwoJeSA9IHQteDsKCWFucyA9IHgqeCArIHkqeTsKCWNvdXQgPDwgYW5zOwoJcmV0dXJuIDA7Cn0=