#include <bits/stdc++.h>
using namespace std;
const int INF = 1e5;
string s[20];
int h, w;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
int main() {
  const int maxx = 62;
  int n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  for (long long b = 0; b < maxx; b++) {
    long long msk = 1LL << b;
    int zero = 0, one = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] & msk)
        one++;
      else
        zero++;
    }
    ans += one * zero * msk;
  }
  cout << ans << endl;
  return 0;
}
