//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 111;
     
using namespace std;
 
int n, q, m, a[maxn], pref[3][65][maxn], y[20][20], cnt, ans;
 
int get(int l, int r, int p, int bit){
	return pref[p][bit][r] - pref[p][bit][l];
}

void solve(){   
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> a[i];

	for (int i = 0; i < 60; i++){
		for (int j = 1; j <= n; j++){
			int x = a[j];
			if (x & (1ll << i))
				pref[1][i][j] = 1;
			else
				pref[0][i][j] = 1;
			pref[1][i][j] += pref[1][i][j - 1];
			pref[0][i][j] += pref[0][i][j - 1];
		}
	}

	for (int i = 1; i < n; i++){
		for (int j = 0; j < 60; j++){
			int h = get(i, n, (((a[i] & (1ll << j)) > 0) + 1) % 2, j);
			//cout << ((a[i] & (1ll << j)) > 0) << " " << h << "  ";
			ans = (ans + h * (1ll << j)) % mod;
		}
		//cout << endl;
	}

	cout << ans;

}
 
main(){
    boost;
	    
	q = 1;
 
	while (q--){
		solve();
	}
}