#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
template <typename T>
void print(const vector<T> &x) {
  int n = x.size();
  for (int i = 0; i < (n); ++i) {
    cout << x[i];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}
template <typename T>
void print(const vector<vector<T>> &x) {
  int n = x.size();
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (x[i].size()); ++j) {
      cout << x[i][j] << " ";
    }
    cout << endl;
  }
}
template <typename T>
void print(const vector<T> &x, int n) {
  for (int i = 0; i < (n); ++i) {
    cout << x[i];
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}
template <typename T>
void print(const vector<vector<T>> &x, int n, int m) {
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (m); ++j) {
      cout << x[i][j] << " ";
    }
    cout << endl;
  }
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
void input_init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long h = 0;
  long long w = 0;
  int j = n - 1;
  for (int i = 0; i < (n); ++i) {
    if (i >= j) break;
    h += a[i];
    w += a[j];
    --j;
  }
  if (n % 2) w += a[n / 2];
  cout << h * h + w * w << endl;
  return 0;
}
