#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll mod = 1e9 + 7;
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A[i];
  vector<vector<ll>> S(N, vector<ll>(60));
  ll tmp = A[N - 1];
  ll idx = 0;
  while (tmp > 0) {
    if (tmp % 2) S[N - 1][idx]++;
    idx++;
    tmp /= 2;
  }
  for (ll i = N - 2; i > 0; i--) {
    for (ll j = 0; j < 60; j++) S[i][j] = S[i + 1][j];
    tmp = A[i];
    idx = 0;
    while (tmp > 0) {
      if (tmp % 2) S[i][idx]++;
      idx++;
      tmp /= 2;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N - 1; i++) {
    tmp = A[i];
    idx = 0;
    while (tmp > 0) {
      ll tmp2 = 1;
      for (ll j = 0; j < idx; j++) {
        tmp2 *= 2;
        tmp2 %= mod;
      }
      if (tmp % 2) {
        ans += ((N - 1 - i) - S[i + 1][idx]) * tmp2 % mod;
      } else {
        ans += S[i + 1][idx] * tmp2 % mod;
      }
      idx += 1;
      tmp /= 2;
      ans %= mod;
    }
    for (ll x = idx; x < 60; x++) {
      ll tmp2 = 1;
      for (ll j = 0; j < x; j++) {
        tmp2 *= 2;
        tmp2 %= mod;
      }
      ans += S[i + 1][x] * tmp2 % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
}
