#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int l = 61;
    ll b[N][l]{};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            ll t = (1ll<<j);
            if ((t & A[i]) != 0) {
               b[i][j] = 1; 
            }
        }
    }
    ll c[N + 1][l]{};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < l; j++) {
            c[i + 1][j] = c[i][j] + b[i][j];
        }
    }
    
    ll ans = 0;
    ll mod = pow(10, 9) + 7;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < l; j++) {
            ll t = 1ll<<j;
            ll k;
            if ((t & A[i]) != 0) {
                k = N - (i + 1) - (c[N][j] - c[i + 1][j]);
            } else {
                k = (c[N][j] - c[i + 1][j]);
            }
            t %= mod;
            ans += k * t;
            ans %= mod;
        }
    }
    
    cout << ans << "\n";
    return 0;
}