#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=50;
//↑templete
signed main(){
	int N;
	cin>>N;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	ll plu=0, and=0;
	for(int i=0;i<N;i++){
		(plu+=(A[i]%MOD)*(N-1))%=MOD;
	}
	for(int i=0;i<61;i++){
		//i bit目が立っている数字の数を数える
		ll cnt=0;
		for(ll a:A)
			if((a>>i)&1)
				cnt++;
		ll temp=cnt*(cnt-1)/2%MOD;
		temp%=MOD;
		temp*=(2LL<<i)%MOD;
		temp%=MOD;
		and+=temp;
		//cout<<i<<" "<<temp<<endl;
		and%=MOD;
		//(and+=(cnt)*(cnt-1)/2%MOD*((1LL<<i)%MOD)%MOD)%=MOD;
	}
	//(and*=2)%=MOD;
	//cout<<plu<<" "<<and<<endl;
	cout<<(plu+MOD-and)%MOD<<endl;
	return 0;
}