#include<bits/stdc++.h>

using namespace std;

long long const mod = 1000000007ll;

int main(){
  int N;
  cin >> N;
  
  vector<int> d(60, 0);
  vector<long long> A(N);
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
    for(int j = 0; j < 60; j++){
      if(A[i] & (1ll << j)) d[j]++;
    }
  }
  
  long long sum = 0ll;
  for(int i = 0; i < N; i++){
    long long k = 1ll;
    for(int j = 0; j < 60; j++){
      if(A[i] & (1ll << j)){
        sum += k * (long long)(N - i - d[j]);
        d[j]--;
      }else{
        sum += k * (long long)d[j];
      }
      k *= 2;
    }
  }
  
  cout << sum % << endl;
  
  return 0;
}