#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const double pi = 3.14159265358979;
long long sumXOR(long long arr[], long long n) {
  long long sum = 0;
  for (long long i = 0; i < 64; i++) {
    long long zc = 0, oc = 0;
    long long idsum = 0;
    for (long long j = 0; j < n; j++) {
      if (arr[j] % 2 == 0)
        zc++;
      else
        oc++;
      arr[j] /= 2;
    }
    idsum = oc * zc * (1 << i);
    sum += idsum;
  }
  return sum;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n], i;
  for (i = 0; i < n; i++) cin >> a[i];
  long long o = sumXOR(a, n);
  cout << o << endl;
}
