#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
            res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
int main()
{
    fast();
    int n;
    cin>>n;
    ll a[n];
    ll cnt[n][60]={};
    loop(n){
        cin>>a[i];
        for(int j=0;j<60;j++){
            if((a[i]&(power(2,j))))
                cnt[i][j]++;
            if(i)
                cnt[i][j]+=cnt[i-1][j];
        }
    }
    ll res=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<60;j++){
            int bit;
            if(i)
                bit=cnt[i][j]-cnt[i-1][j];
            else
                bit=cnt[i][j];
            if(bit){
                res+=power(2,j)*(n-i-1-(cnt[n-1][j]-cnt[i][j]));
            }
            else
                res+=power(2,j)*(cnt[n-1][j]-cnt[i][j]);
            res%=mod;
        }
    }
    cout<<res%mod;

}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/
