#include <bits/stdc++.h>
using namespace std;
const long long mod1 = 998244353, p = 1e9 + 7;
const long long MAX_N = 100005, MAX_M = 200010;
long long n, res = 0, b[22];
void Solve() {
  cin >> n;
  for (long long i = 0, s; i < n; i++) {
    cin >> s;
    long long t = 0;
    while (s) {
      b[t++] += (s % 2);
      s /= 2;
    }
  }
  while (true) {
    long long t = 0;
    for (long long i = 0; i < 20; i++) {
      if (b[i] > 0) {
        t |= (1 << i);
        b[i]--;
      }
    }
    if (t == 0) {
      break;
    } else {
      res += t * t;
    }
  }
  cout << res;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long TC = 1;
  while (TC--) Solve();
  return 0;
}
