#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

#define keta setprecision(15) //15桁表示

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;
	vector<ull> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	vector<vector<ull>> ket(n, vector<ll>(61,0));
    ull ke=0; 
	for (int i = 0; i < n; i++)
	{
		ll tmp = a[i];
		ll k = 0;
		while (tmp!=0)
		{
			ket[i][k] += (tmp & 1);
			k++;
			tmp=tmp >> 1;
		}
		ke = max(ke, k);
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < ke; j++)
		{
			ket[i][j] += ket[i - 1][j];
          ket[i][j]%=1000000007;
		}
	}

    ull ans = 0;
	for (int i = 0; i < n-1; i++)
	{
		for (int j = 0; j < ke; j++)
		{
			if ((a[i] >> j) % 2==0)
			{
				ans += (pow(2, j)%1000000007) * (ket[n - 1][j] - ket[i][j]);
				ans %= 1000000007;
			}
			else
			{
				ans += (pow(2, j)%1000000007) * ((n-(i+1))-(ket[n - 1][j] - ket[i][j]));
				ans %= 1000000007;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
