#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
struct greateri {
  template <class T>
  bool operator()(T const &a, T const &b) const {
    return a > b;
  }
};
using namespace std;
vector<long long> arr;
long long int sumXOR(int n) {
  long long int sum = 0;
  for (int i = 0; i < 32; i++) {
    int zc = 0, oc = 0;
    long long int idsum = 0;
    for (int 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;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int yo;
    cin >> yo;
    arr.push_back(yo);
  }
  cout << sumXOR(n);
  return 0;
}
