#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i;
  cin >> n;
  vector<long long> r;
  for (i = 0; i < n; i++) {
    long long p;
    cin >> p;
    r.push_back(p);
  }
  sort(r.begin(), r.end());
  if (n == 1)
    cout << r[0] * r[0] << endl;
  else {
    vector<long long> c;
    long long j, d = 0, s = 0, s1 = 0;
    for (i = 0; i < 20; i++) c.push_back((long long)0);
    for (i = 0; i < n; i++) {
      for (j = 19; j >= 0; j--) {
        if (r[i] & (1 << j)) {
          r[i] -= (long long)pow(2, j);
          c[j]++;
        }
      }
    }
    while (d != 20) {
      d = 0;
      for (i = 0; i < 20; i++) {
        if (c[i] == 0)
          d++;
        else {
          c[i]--;
          s1 += (long long)pow(2, i);
        }
      }
      s += (long long)pow(s1, (long long)2);
      s1 = 0;
    }
    cout << s << endl;
  }
  return 0;
}
