v#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 300000;

int main(){
    
    int n;
    int64_t mod = INF;
    int64_t ans=0;
    int64_t a[maxn];
    cin >> n;
    rep(i,n)cin >> a[i];
    
    int64_t b = 1;
    rep(i,61){
        int64_t c = b;
        b=b*2;
        int64_t A=0,B=0;
        rep(j,n){
            int64_t t = a[j]%b;
            if(c<=t)A++;
            else B++;
        }
        
        int64_t add = (c*A%mod*B%mod)%mod;
        ans = (ans+add)%mod;
        //if(ans<0)ans+=mod;
    }
    
    cout << ans <<endl;
    
    return 0;
}
