#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int const MAXN=300100, MOD=1e9+7;
int suff[MAXN][62], scomp[MAXN][62];
ll ans=0;
ll rd()
{
    ll res = 0;
    char ch = 0;
    while(ch < '0') ch = getchar_unlocked();
    for(; ch >= '0'; ch = getchar_unlocked()) res = res * 10 + ch - '0';
    return res;
}

void wr(ll v)
{
    char buf[28];
    int p = 0;
    if(v == 0) buf[p++] = 0;
    for(; v; v /= 10) buf[p++] = v % 10;
    while(p--) putchar_unlocked(buf[p] + '0');
}
void my_pow(int base, int esp, int times){
	if(times==0)
		return;
	int val=power(2,esp,1e9+7);
	ans=(ans+(val*times)%MOD)%MOD;
}
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n;
	n=rd();
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		v[i]=rd();
	for(int i=0;i<n;i++){
		ll esp=1, p=0;
		while(esp<=v[i]){
			esp*=2;
			p++;
		}
		ll copy=v[i];
		while(copy){
			if(copy>=esp){
				copy-=esp;
				scomp[i][p]=1;
			}
			esp/=2;
			p--;
		}
	}
	for(int i=n-1;i>=0;i--){
		for(int j=0;j<62;j++)
			suff[i][j]=suff[i+1][j]+scomp[i][j];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<60;j++){
			if(scomp[i][j]){
				int times=n-i-suff[i][j];
				my_pow(2,j,times);
			}
			else{
				int times=suff[i][j];
				my_pow(2,j,times);
			}
		}
	wr(ans);
}