#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
ll bp(ll a, ll n) {
    ll res = 1;
    while(n) {
        if(n % 2)
            res = (res * a) % MOD;
        a = (a * a) % MOD; 
        n /= 2;
    }return res;   
}
ll a[N];
ll o[N];
ll z[N];
void add(ll n) {
    for(ll i = 0; i < 60; ++i) {
        o[i] += (n >> i) & 1;
        z[i] += 1ll - ((n >> i) & 1);
    }
}
void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
    }  
    ll ans = 0;
    for(ll i = n; i >= 1; --i) {     // 1 1 0     0 0 1
        for(ll j = 0; j < 60; ++j) { //  010
            if((a[i] >> j) & 1) {
                
                ans += z[j] * bp(2, j);
            }
            else {
                ans += o[j] * bp(2, j);
            }
            ans %= MOD;
        }
        add(a[i]);
    }
    cout << ans;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}