#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#include <boost/multiprecision/cpp_int.hpp>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
const int MOD = 1e9+7;
using namespace std;
namespace mp = boost::multiprecision;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;
const int MX = 777777 + 5;
int fac[MX+5],inv[MX+5];

int power(int x,int y,int p){
    int res=1;
    x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

void init(){
  int n=MX+4;
	fac[0] = 1;
  for(int i=0;i<n;++i)fac[i+1]=fac[i]*(i+1)%MOD;
  inv[n]=power(fac[n],MOD-2,MOD);
  for(int i=n-1;i>=0;--i)inv[i]=inv[i+1]*(i+1)%MOD;
}
// nPk = nCk * fac[k]
int comb(int n,int r){return (fac[n]*inv[r])%MOD*inv[n-r]%MOD;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    init();
    int N; cin >> N;
    int bkt[61];
    rep(i,61) bkt[i]=0;
    mp::cpp_int sum=0;
    rep(i,N){
        int a; cin >> a;
        sum=((a*(N-1))%MOD+sum)%MOD;
        rep(j,61){
            if((a>>j)&1){
                bkt[j]++;
            }
        }
    }
    rep(j,61){
        if(bkt[j]>=2){
            sum-=((2*comb(bkt[j],2))%MOD*power(2,j,MOD))%MOD;
        }
    }
    cout << sum << endl;
}
