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

const int NRB = 60;
const int NMAX = 3e5 + 5;
const int MOD = 1e9 + 7;

int n;
int A[NMAX];
int P[NRB][NMAX];

void precalc() {
    for (int i = n; i >= 1; i--) {
        for (int bit = 0; bit < NRB; bit++) {
            P[bit][i] = P[bit][i + 1] + ((A[i] >> bit) & 1LL);
        }
    }
}

inline add(long long &x, long long a) {
    x = (x + a) % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> A[i];
    
    precalc();

    /*cout << P[0][n];
    return 0;*/

    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        long long aici = 0;
        for (int bit = 0; bit < NRB; bit++) {
            if (A[i] & (1LL << bit)) {
                add(aici, (n - i - P[bit][i + 1]) * (1LL << bit));
            }
            else {
                add(aici, P[bit][i + 1] * (1LL << bit));
            }
        }

        add(ans, aici);
        //cout << aici << " ";
    }

    cout << ans;


    return 0;
}