#include <algorithm>
#include <string.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9 + 7;
const int N = 3e5 + 10;
ll x[N], p[64], sum1[N], sum0[N];
int main()
{
    p[0] = 1;
    for (int i = 1; i < 63; i++)
        p[i] = (p[i - 1] * 2ll;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    ll ans = 0;
    for (int i = 0; i <63; i++)
    {
            memset(sum1, 0, sizeof(sum1));
            memset(sum0, 0, sizeof(sum0));
            for (int j = n; j >= 1; j--)
            {
                sum1[j] = sum1[j + 1];
                sum0[j] = sum0[j + 1];
                if ((x[j] >> i) & 1)
                    sum1[j]++;
                else
                    sum0[j]++;
                if ((x[j] >> i) & 1)
                {
                    ll temp = (sum0[j + 1] % mod * p[i] % mod) % mod;
                    ans = (ans % mod + temp % mod) % mod;
                }
                else
                {
                    ll temp = (sum1[j + 1] % mod * p[i] % mod) % mod;
                    ans = (ans % mod + temp % mod) % mod;
                }
            }
    }
    cout << ans % mod << endl;
    return 0;
}
