#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
const ll MOD = 1e9 + 7, N = 3e5 + 10;
ll a[N];
ll val[61];
ll power(ll x, ll y) {
  ll ans = 1;
  if (y == 1) return x % MOD;
  x = x % MOD, y = y % (MOD - 1);
  while (y) {
    if (y & 1) ans = (ans * x) % MOD;
    x *= x;
    x = x % MOD;
    y >>= 1;
  }
  return ans;
}
ll inv(ll x) { return power(x, MOD - 2); }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  reverse(a, a + n);
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++) {
    for (ll j = 0; j < 61; j++) {
      if (a[i] & (1ll << j)) {
        val[j]++;
      }
    }
    for (ll j = 0; j < 61; j++) {
      if (a[i + 1] & (1ll << j)) {
        ans += (i + 1 - val[j]) * (1 << j);
        ans = ans % MOD;
      } else {
        ans += (val[j]) * (1ll << j);
        ans = ans % MOD;
      }
    }
  }
  ans = ans % MOD;
  cout << ans << '\n';
  return 0;
}
