#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;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 
 
 
#define pb push_back
 
// #define mp make_pair 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
 
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define itt iterator
#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
 
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
 
 
// #define maxn 200005
 
 
 
 
 
signed main() {
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout); 
	// #endif

	int n;
	cin>>n;

	ll mod=1e9;
	mod+=7;

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

	ll ans=0;

	for(ll b=0;b<62;b++)
	{
		ll pre[n];
		initialise(pre,(ll)0);
		ll sub=0;

		if(a[n-1]&(1<<b)) pre[n-1]=1;

		for(int i=n-2;i>=0;i--)
		{
			pre[i]+=pre[i+1];
			if(a[i+1]&(1<<b)) pre[i]+=1;
		}
		for(int i=0;i<n-1;i++)
		{
			if(a[i]&(1<<b)) sub+=(n-i-1)-pre[i];
			else sub+=pre[i];
		}
		sub%=mod;
		sub*=(1<<b)%mod;
		ans+=sub;
		ans%=mod;
	}
 	cout<<ans%mod<<'\n';

	return 0;
}

