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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    ll sum=0;
    rep(i,60)
        ll c=0,d=1;
        for(int j=i+1;j<N;j++){
              (A[j]&1)?c++:1;
              A[j]>>1;
        }
        sum=sum+(c*(N-c)*d)%MOD;
        d=2*d%MOD;
    }
    cout<<sum%MOD<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}