#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, n, ans = 0, sum, sqSum;
  cin >> n;
  long long arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  for (i = 0, j = n - 1; i < j; i++, j--) {
    sum = arr[i] + arr[j];
    sqSum = sum * sum;
    ans += sqSum;
  }
  cout << ans << endl;
  return 0;
}
