#include<iostream>
#include<algorithm>
using namespace std;
int n, h[301];
int main()
{
cin >> n;
int right = n, left = 0;
long long ans = 0;
for (int i = 1; i <= n; i++)
{
cin >> h[i];
}
sort(h + 1, h + 1 + n);
h[0] = 0;
while (left < right)
{
ans += (long long)((h[right] - h[left]) * (h[right] - h[left]));
left++;
ans += (long long)((h[right] - h[left]) * (h[right] - h[left]));
right--;
}
cout << ans << endl;
}
#include<iostream>
#include<algorithm>
using namespace std;
int n, h[301];
int main()
{
cin >> n;
int right = n, left = 0;
long long ans = 0;
for (int i = 1; i <= n; i++)
{
cin >> h[i];
}
sort(h + 1, h + 1 + n);
h[0] = 0;
while (left<right)
{
ans += (long long)((h[right] - h[left]) * (h[right] - h[left]));
if (left % 2) right--;
else left++;
}
cout << ans << endl;
}