#include <bits/stdc++.h>
using namespace std;
int dp[1000001];
void coin_change() {
  int INF = 10000000;
  int t;
  cin >> t;
  while (t--) {
    int n, s;
    cin >> n >> s;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 1; i <= s; i++) dp[i] = INF;
    for (int i = 1; i <= s; i++) {
      int ans = INF;
      for (int j = 0; j < n; j++) {
        if (a[j] <= i) {
          ans = min(ans, dp[i - a[j]]);
        }
        if (ans == INF) {
          dp[i] = INF;
        } else {
          dp[i] = ans + 1;
        }
      }
    }
    if (dp[s] == INF)
      cout << "-1" << endl;
    else
      cout << dp[s] << endl;
  }
}
void solve() {
  set<char> st;
  map<int, string> mp;
  mp[0] = "CHAT WITH HER!";
  mp[1] = "IGNORE HIM!";
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    st.insert(s[i]);
  }
  cout << mp[st.size() % 2];
}
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n == 2) {
    cout << (a[0] + a[1]) * (a[0] + a[1]);
    return 0;
  }
  sort(a, a + n);
  int i = 0, j = n - 1;
  long long ans = 0;
  while (i < j) {
    long long sum;
    sum = a[i++] + a[j--];
    sum = sum * sum;
    ans += sum;
  }
  cout << ans;
}
