#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
ll modpow(ll x, ll n, ll mod = MOD) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < 60; ++i) {
    int cnt1 = 0;
    for (int j = 0; j < n; ++j) {
      if (a[j] & (1LL << i)) {
        (ans += (1LL << i) * (j - cnt1) % MOD) %= MOD;
        cnt1++;
      } else {
        (ans += (1LL << i) * cnt1 % MOD) %= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
