
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<ld> vld;

#define fi first
#define se second

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const ll inf = ll(1e18);
const int MOD = (1e9 + 7);

int main() 
{

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	#ifdef DEBUG_
		freopen("input.txt","r",stdin);
		clock_t start = clock();
	#endif
	cout.setf(ios::fixed), cout.precision(20);
	//code begins here

	ll n;
	cin >> n;
	ll arr[n];
	
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	
	vll arr1[n];
	ll sum[n][60];
	ll pw[60];
	pw[0] = (ll)1;
	for(int i=1;i<60;i++){
		pw[i] = (pw[i-1]*((ll)2))%MOD;
		//cout<<pw[i]<<" ";
	}
	//cout<<"\n";
	for(int i=0;i<n;i++){
		
		ll temp =  arr[i];
		while(temp){
			if(temp%2==1) arr1[i].push_back(1);
			else arr1[i].push_back(0);
			temp = temp >>1 ;
		}
		//reverse(arr1[i].begin(),arr1[i].end());
		while(arr1[i].size()<60){
			arr1[i].push_back(0);
		}
		
	}
	for(int j=n-1;j>=0;j--){
		for(int k=0;k<60;k++){
			sum[j][k] = arr1[j][k];
		}
		for(int i=0;i<60;i++)
		cout<<sum[j][i];
		cout<<"\n";
	}

	for(int j=n-2;j>=0;j--){
		for(int k=0;k<60;k++){
			sum[j][k] = sum[j][k] + sum[j+1][k];
		}
		for(int i=0;i<60;i++)
		cout<<sum[j][i];
		cout<<"\n";
	}

	ll ans = 0;
	
	for(int i=0;i<n-1;i++){
		for(int j=0;j<60;j++){
			ll cnt = 0;
			if(arr1[i][j]==1){
				assert((n-1-i-sum[i+1][j]) >= 0);
				cnt = (n-1-i-sum[i+1][j]);
			}
			else cnt = sum[i+1][j];
			ans += (pw[j]*cnt)%MOD;
		}
		//cout<<i<<" "<<ans<<"\n";
	}
	cout<<ans%MOD<<"\n";
	//End of code 
	#ifdef DEBUG_
		cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}

