#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long N;
vector<long long> A;
int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < (N); ++i) cin >> A[i];
  long long ans = 0;
  for (int i = 0; i < 60; i++) {
    long long cnt = 0;
    for (int j = 0; j < N; j++) {
      if (A[j] >> i & 1) cnt++;
    }
    long long pat = cnt * (N - cnt);
    long long val = 1LL << i;
    ans += pat * val;
  }
  cout << ans << endl;
}
