#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> r(63);
  for (ll i = 1; i < n; i++) {
    for (ll j = 0; j < 63; j++) {
      if (a[i] & (1LL << j)) {
        r[j]++;
      }
    }
  }
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++) {
    for (ll j = 0; j < 63; j++) {
      if (a[i] & (1LL << j)) {
        ans += (1LL << j) * (n - 1 - i - r[j]);
      } else {
        ans += (1LL << j) * r[j];
      }
      ans %= 1000000007;
    }
    for (ll j = 0; j < 63; j++) {
      if (a[i + 1] & (1LL << j)) {
        r[j]--;
      }
    }
  }
  cout << ans << endl;
}
