#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e2 + 2;
int n;
int a[MAXN];
long long ans;
bool cmp(int x, int y) {
return x > y;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
ans += a[0] * a[0];
sort(a, a + n, cmp);
int left_, right_;
n -= 1;
left_ = 0;
right_ = n;
while (n > 0) {
int temp = a[left_] - a[right_];
ans += temp * temp;
left_++;
n--;
}
cout << ans;
return 0;
}