#include <bits/stdc++.h>
using namespace std;
int n;
int a[300010];
long long ans = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n / 2; ++i) {
    long long sum = a[i] + a[n - i + 1];
    ans += sum * sum;
  }
  cout << ans;
}
