#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long z = 1000000000;
const long long N = 1e9 + 1;
const long long INF = 1e18;
long long mod2 = 998244353;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
long long t, n, m;
long long powe(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long t = powe(x, y / 2);
  t = (t * t) % mod2;
  if (y % 2 == 1) t = (t * x) % mod2;
  return t;
}
void solve() {
  cin >> n;
  vector<long long> a(n);
  vector<long long> bits(32, 0);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    long long pos = 0;
    long long v = a[i];
    while (v) {
      bits[pos] += (v & 1);
      v >>= 1;
      pos++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long val = 0;
    for (long long j = 0; j < 32; j++) {
      if (bits[j]) {
        val += (1 << j);
        bits[j]--;
      }
    }
    if (val == 0) break;
    ans += val * val;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  t = 1;
  while (t--) {
    solve();
  }
}
