#include <bits/stdc++.h>
using namespace std;
const long long NRB = 60;
const long long NMAX = 3e5 + 5;
const long long MOD = 1e9 + 7;
long long n;
long long A[NMAX];
long long P[NRB][NMAX];
void precalc() {
  for (long long i = n; i >= 1; i--) {
    for (long long bit = 0; bit < NRB; bit++) {
      P[bit][i] = P[bit][i + 1] + ((A[i] >> bit) & 1LL);
    }
  }
}
inline void add(long long &x, long long a) { x = (x + a) % MOD; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> A[i];
  precalc();
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long aici = 0;
    for (long long bit = 0; bit < NRB; bit++) {
      if (A[i] & (1LL << bit)) {
        add(aici, (n - i - P[bit][i + 1]) * (1LL << bit));
      } else {
        add(aici, P[bit][i + 1] * (1LL << bit));
      }
    }
    add(ans, aici);
  }
  cout << ans;
  return 0;
}
