#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll n,i,k,j;
    cin >> n;
    vector< ll >v(n);
    for(i = 0; i < n; i++)cin>>v[i];
    vector<pii>answer(61,{0,0});
    rep(i,0,n){
        rep(j,0,61){
            if(v[i] & (1LL << j) )answer[j].ff++;
            else answer[j].ss++;
        }
    }
    ll ans = 0,mod = 1e9+7;
    rep(i,0,61){
        ll k1 = (answer[i].ff * answer[i].ss)%mod ;
        ll k2 = (1LL << i)%mod;
        k1 = (k1*k2)%mod;
        ans = ((ans % mod) + (k1 % mod)) % mod;
    }
    cout << ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}

#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n;
int v[300005];
int suf[64][300005][2];

signed main(){
    FASTER;
    cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    
    for(int i=0;i<64;i++){
        for(int j=n;j>=1;j--){
            suf[i][j][1]=suf[i][j+1][1]+((v[j]>>i)&1);
            suf[i][j][0]=suf[i][j+1][0]+(1-((v[j]>>i)&1));
        }
    }
    int ans=0;
    for(int i=0;i<64;i++){
        for(int j=n;j>=1;j--){
            int z=suf[i][j+1][0];
            int o=suf[i][j+1][1];
            if((v[j]>>i)&1){
                ans+=(1LL<<i)%MOD*z%MOD;
            }else{
                ans+=(1LL<<i)%MOD*o%MOD;
            }
            ans%=MOD;
        }
    }
    cout<<ans;
}

