#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int64_t n;
  cin >> n;
  int64_t a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  std::vector<int64_t> v(64, 0);
  int64_t ans = 0;
  int64_t zero, one;
  for (int64_t i = n - 1; i >= 0; i--) {
    for (int k = 0; k < 64; k++) {
      one = v[k];
      zero = (n - 1 - i) - one;
      int p1 = k / 2;
      int p2 = k - k / 2;
      int64_t tmp = (1 << p1);
      tmp = tmp * (1 << p2);
      if ((a[i] & tmp) == 0) {
        ans = (ans + ((1 << k) % MOD) * (one % MOD)) % MOD;
      } else {
        ans = (ans + ((1 << k) % MOD) * (zero % MOD)) % MOD;
        v[k]++;
      }
      ans = ans % MOD;
    }
  }
  cout << (ans) << endl;
}
