#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  long long int ans = 0;
  for (int i = 0; i < n; i++) ans += arr[i] * arr[i];
  long long int store = 0;
  for (int i = 0; i < (n) / 2; i++) {
    ans += 2 * store * arr[i];
    store += arr[i];
  }
  store = 0;
  for (int i = n / 2; i < n; i++) {
    ans += 2 * store * arr[i];
    store += arr[i];
  }
  cout << ans;
}
