#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
const ll MOD=1000000007;
ll n,ans=0;
ll one=1;
void Main(){
    cin>>n;
    vector<ll> l(n);
    For(i,0,n)cin>>l.at(i);
    ll bit[n+10][100]={};
    For(i,0,n){
        For(j,0,64){
            bit[i+1][j]=bit[i][j]+(l[i]/(one<<j)%2);
            //cout<<bit[i][j]<<" ";
        }
        //cout<<endl;
    }
    For(i,0,n-1){
        For(j,0,64){
            int t;
            if(l[i]/(one<<j)%2==0){
                t=bit[n][j]-bit[i+1][j];
            }
            else{
                t=n-1-i-(bit[n][j]-bit[i+1][j]);
            }
            //cout<<(one<<j)*t<<" ";
            ans+=(one<<j)*t;
            ans%=MOD;
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}
