#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
double EPS = 1e-8;
template <typename T>
T chmax(T& a, const T& b) {
  return a = (a > b ? a : b);
}
template <typename T>
T chmin(T& a, const T& b) {
  return a = (a < b ? a : b);
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = (0); i < (int)(n); i++) cin >> a[i];
  vector<int> cnt(61);
  auto addCnt = [&](long long k) {
    for (int i = (0); i < (int)(61); i++)
      if (k & (1LL << i)) cnt[i]++;
  };
  addCnt(a[n - 1]);
  long long ans = 0LL;
  long long num = 1;
  for (int i = (int)(n - 1 - 1); i >= (int)(0); i--) {
    for (int j = (0); j < (int)(61); j++) {
      if (a[i] & (1LL << j)) {
        (ans += (1LL << j) * (num - cnt[j])) %= MOD;
      } else {
        (ans += (1LL << j) * (cnt[j])) %= MOD;
      }
    }
    addCnt(a[i]);
    ++num;
  }
  cout << ans << endl;
  return 0;
}
