#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(){
int N;
 cin >> N;
 int64_t a[N];
 int64_t sum = 0;
 int i;
 int j;
 for(i=0;i<N;++i){
     cin >> a[i];
   }
 for(i=0;i<60++i){
    int count = 0;
  for(j=0;j<N;++j){
    count += a[i] % pow(2,i);
    sum = (sum +count * (N - count)*(pow(2,i)%1000000007))%1000000007;
   }}
  cout << sum << endl; 
  return 0;
}