#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll pow2 = 1;
    ll sum = 0;
    ll mod = 7LL + 1e9;
    rep(_i, 61) {
        ll one = 0, zero = 0;
        rep(i, n) {
            ll v = A[i] % 2;
            if (v == 1) one++;
            else zero++;
            A[i] /= 2;
        }

        sum += (one * zero % mod) * pow2 % mod;
        sum %= mod;

        pow2 *= 2;
        pow2 %= mod;
    }

    put(sum);
}
signed main(){ Main();return 0;}
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define ld long double
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;


const int mod = 1000000007  ;
const int inf = 100005;
const int N = 3e5, M = N;
ll i,j,n,m,idx,cnt;
char d[31][31];
int dx[] = {-1,1,0,0};
int dy[] = {0,0,-1,1};


void solve() {
 ll n;
 cin>>n;

 vl vec(61);
 ll ans = 0,x;
 cin>>x;
 fo(i,0,61) {
    if(x & (1LL<<i)) vec[i]++;
 }
 ll k;
 fo(i,1,n) {
    cin>>x;
    fo(j,0,61) {
        if(x & (1LL<<j)) {
            k = i - vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
            vec[j]++;
        }
        else {
            k = vec[j];
            ans = (ans%mod + ((1LL<<j)%mod * k%mod)%mod)%mod;
        }
    }

 }
 cout<<ans<<"\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}


