#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 1000000007  ;
const int inf = 100005;
const int N = 3e5, M = N;
ll i,j,n,m,idx,cnt;
char d[31][31];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};


void solve() {
 ll n;
 cin>>n;

 vl vec(61);
 ll ans = 0,x;
 cin>>x;
 fo(i,0,61) {
    if(x & (1LL<<i)) vec[i]++;
 }
 ll k;
 fo(i,1,n) {
    cin>>x;
    fo(j,0,61) {
        if(x & (1LL<<j)) {
            k = i - vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
            vec[j]++;
        }
        else {
            k = vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
        }
    }

 }
 cout<<ans<<"\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}



#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
void solve() {
	int n;
	cin >> n;
	map<int,set<int> > L, R, U, D;
	map<int, set<int> > L2, R2, U2, D2;
	map<int, set<int> > L3, R3, U3, D3;
	rep(i, 0, n) {
		int x, y;
		char dir;
		cin >> x >> y >> dir;
		if (dir == 'U') {
			U[x].insert(y);
			U2[x + y].insert(y);
			U3[x - y].insert(y);
		}
		if (dir == 'D') {
			D[x].insert(y);
			D2[x + y].insert(y);
			D3[x - y].insert(y);
		}
		if (dir == 'L') {
			L[y].insert(x);
			L2[x + y].insert(y);
			L3[x - y].insert(y);
		}
		if (dir == 'R') {
			R[y].insert(x);
			R2[x + y].insert(y);
			R3[x - y].insert(y);
		}
	}
	int dis = INT_MAX, dis2 = INT_MAX;
	for (auto m : U) {
		set<int> up = m.second;
		set<int> down = D[m.first];
		for (auto y : up) {
			auto it = down.lower_bound(y);
			if (it == down.end()) {
				break;
			}
			else {
				dis = min(dis, (*it) - y);
			}
		}
	}
	for (auto m : R) {
		set<int> right = m.second;
		set<int> left = L[m.first];
		for (auto x : right) {
			auto it = left.lower_bound(x);
			if (it == left.end()) {
				break;
			}
			else {
				dis = min(dis, (*it) - x);
			}
		}
	}
	for (auto m : L2) {
		int sum = m.first;
		set<int> left = m.second;
		for (auto y : left) {
			set<int> down = D2[sum];
			auto it = down.lower_bound(y);
			if (it == down.end()) {
				break;
			}
			else {
				dis2 = min(dis2, (*it) - y);
			}
		}
	}
	for (auto m : R3) {
		int diff = m.first;
		set<int> right = m.second;
		for (auto y : right) {
			set<int> down = D3[diff];
			auto it = down.lower_bound(y);
			if (it == down.end()) {
				break;
			}
			else {
				dis2 = min(dis2, (*it) - y);
			}
		}
	}
	for (auto m : U2) {
		int sum = m.first;
		set<int> up = m.second;
		for (auto y : up) {
			set<int> right = R2[sum];
			auto it = right.upper_bound(y);
			if (it == right.end()) {
				break;
			}
			else {
				dis2 = min(dis2, (*it) - y);
			}
		}
	}
	for (auto m : U3) {
		int diff = m.first;
		set<int> up = m.second;
		for (auto y : up) {
			set<int> left = L3[diff];
			auto it = left.upper_bound(y);
			if (it == left.end()) {
				break;
			}
			else {
				dis2 = min(dis2, (*it) - y);
			}
		}
	}
	if (dis == INT_MAX && dis2 == INT_MAX) {
		cout << "SAFE" << endl;
	}
	else {
		int ans = INT_MAX;
		if (dis != INT_MAX) {
			ans = min(ans, dis * 5);
		}
		if (dis2 != INT_MAX) {
			ans = min(ans, dis2 * 10);
		}
		cout << ans << endl;
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}

