#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=1e5+4;
const int mod=1e9+7;

ll n,pre[65][N],a,dizi[N],ans;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>dizi[i];
	}
	for(ll i=0;i<63;i++){
		pre[i][0]=0;
		for(ll j=1;j<=n;j++){
			pre[i][j]=pre[i][j-1]+((dizi[j]&((ll)1<<i))!=0);
			//cout<<i<<" "<<j<<" "<<pre[i][j]<<endl;
		}
	}
	//cout<<pre[0][3]-pre[0][1]<<endl;
	for(int i=0;i<61;i++){
		for(int j=1;j<=n;j++){
			if(((dizi[j]&((ll)1<<i))==0)ans+=(pre[i][n]-pre[i][j])%mod)*(pow(2,i)%mod);
			else ans+=((n-(pre[i][n]-pre[i][j]+j))%mod)*(pow(2,i)%mod);
			ans%=mod;
		}
	}
	cout<<ans<<endl;
return 0;
}