#include <bits/stdc++.h>
using namespace std;
int static fast = []() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();
int main() {
  int n;
  uint64_t mod = 1e9 + 7;
  cin >> n;
  vector<uint64_t> arr(n, 0);
  for (uint64_t& val : arr) cin >> val;
  vector<uint64_t> vec(60, 0);
  vector<uint64_t> fac(60, 0);
  uint64_t ans = 0;
  fac[0] = 1;
  for (int i = 1; i < 60; i++) {
    fac[i] = (fac[i - 1] * 2) % mod;
  }
  uint64_t cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int d = 0; d < 60; d++) {
      if ((arr[i] & ((uint64_t)(1) << d)) == 0) {
        ans += fac[d] * vec[d];
      } else {
        ans += fac[d] * (cnt - vec[d]);
        vec[d] += 1;
      }
      ans %= mod;
    }
    cnt += 1;
  }
  cout << ans << endl;
  return 0;
}
