#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> A(n);
  for (auto& _a : A) cin >> _a;
  ll ans = 0;
  for (ll b = 0; b < 62; ++b) {
    int n1 = 0;
    for (int i = 0; i < n; ++i) {
      int n0 = i - n1;
      if (A[i] >> b & 1) {
        ans += n0 * (1LL << b);
        ++n1;
      } else {
        ans += n1 * (1LL << b);
      }
      ans %= mod;
    }
  }
  ans %= mod;
  cout << ans << '\n';
}
