//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define ll long long
#define ull unsigned long long
#define int long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
                                                                    
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 10;
int n ;
int a[N] , cnt[62][2];
main(){
	scanf("%lld" , &n);
	rep(i , 1 , n)
		scanf("%lld" , a + i);

	int ans = 0;

	repb(i , n , 1){
		rep(j , 0 , 60){
			if(a[i] & (1ll << j)){
				ans += ((1ll << j)*(cnt[j][0]))%mod;
				ans %= mod;
			}else ans += ((1ll << j)*(cnt[j][1]))%mod , ans %= mod;
		}
		rep(j , 0 , 60){
			if(a[i] & (1ll << j)){
				cnt[j][1]++;
			}else cnt[j][0]++;
		}
	}
	cout << ans;
		
}