#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
const ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  V<V<P>> bits(n, V<P>(61, {0, 0}));
  for (int i = 1; i < n; i++) {
    ll num = a[i];
    for (int j = 0; j < (61); ++j) {
      bits[i][j] = bits[i - 1][j];
      if (num >> j & 1)
        bits[i][j].first++;
      else
        bits[i][j].second++;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (n - 1); ++i) {
    V<P> b = bits[n - 1];
    for (int j = 0; j < (61); ++j) {
      b[j].first -= bits[i][j].first;
      b[j].second -= bits[i][j].second;
    }
    ll e = 1;
    for (int j = 0; j < (61); ++j) {
      if (a[i] >> j & 1) {
        ans += b[j].second * e % mod;
      } else {
        ans += b[j].first * e % mod;
      }
      ans %= mod;
      e <<= 1;
    }
  }
  cout << ans << endl;
}
