#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef pair<int,int> p;
//const ll big=998244353;
const ll big=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

ll f(vector<ll> &a){
    vector<ll> sums(61);
    ll len=a.size();
    rep(i,len){
        bitset<61> now(a[i]);
        rep(j,61){
            sums[j]+=now[j];
        }
    }
    
    ll ans=0;
    ll pows=1;
    rep(i,61){
        ans+=(((len-sums[i])%big)*sum[i])%big*pows)%big;
        ans%=big;
        pows*=2;
        pows%=big;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n;cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    /*a xor b==a+b-2*(a&b)
    a&b+a&c+...
    */
   ll ans=0;
   rep(i,n)ans=(ans+a[i]*(n-1))%big;
   cout << f(a) << endl;
}
