#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<int>> bits(n, V<int>(61, 0));
  for (int i = 0; i < (n); ++i) {
    ll num = a[i];
    for (int j = 0; j < (61); ++j) {
      bits[i][j] = (i > 0) ? bits[i - 1][j] : 0;
      if (num >> j & 1) bits[i][j]++;
    }
  }
  ll ans = 0;
  for (int i = 0; i < (n - 1); ++i) {
    V<int> b(61);
    for (int j = 0; j < (61); ++j) {
      b[j] = bits[n - 1][j] - bits[i][j];
    }
    ll e = 1;
    for (int j = 0; j < (61); ++j) {
      if (a[i] >> j & 1) {
        ans += (n - i - 1 - b[j]) * e;
      } else {
        ans += b[j] * e;
      }
      ans %= mod;
      e <<= 1;
    }
  }
  cout << ans << endl;
}
