#include <bits/stdc++.h>
using namespace std;
const int N = 3e5, mod = 1e9 + 7;
long long cum[N][61], x[N];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> x[i];
  for (int i = n; i >= 1; --i) {
    for (long long j = 0; j <= 60; ++j) {
      if (x[i] & (1LL << j)) cum[i][j]++;
      cum[i][j] += cum[i + 1][j];
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    for (long long j = 0; j <= 60; ++j) {
      long long q = cum[i + 1][j];
      long long t = (1LL << j);
      t %= mod;
      if (x[i] & t)
        sum = ((n - i - q) % mod * t) % mod + sum % mod;
      else
        sum = (q % mod * t) % mod + sum % mod;
      sum %= mod;
    }
  }
  cout << sum << "\n";
  return 0;
}
