#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 7;
const long long MOD = 1e9 + 7;
long long tree[4 * MAXN][62][2], a[MAXN], poten[62];
inline long long soma_mod(long long x, long long y) { return (x + y) % MOD; }
void upt(int idx, int l, int r, int pos, int bt, int tp) {
  if (l == r) {
    tree[idx][bt][tp]++;
    return;
  }
  if (pos <= (l + r) / 2)
    upt(2 * idx, l, (l + r) / 2, pos, bt, tp);
  else
    upt(2 * idx + 1, (l + r) / 2 + 1, r, pos, bt, tp);
  tree[idx][bt][tp] = tree[2 * idx][bt][tp] + tree[2 * idx + 1][bt][tp];
}
long long query(int idx, int l, int r, int ql, int qr, int bt, int tp) {
  if (r < ql || l > qr) return 0;
  if (l >= ql && r <= qr) return tree[idx][bt][tp];
  return query(2 * idx, l, (l + r) / 2, ql, qr, bt, tp) +
         query(2 * idx + 1, (l + r) / 2 + 1, r, ql, qr, bt, tp);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  poten[0] = 1;
  for (int i = 1; i < 60; i++) poten[i] = (2LL * poten[i - 1]) % MOD;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    for (long long j = 0; j < 60; j++) {
      if (((1LL << j) & a[i]))
        upt(1, 1, n, i, j, 1);
      else
        upt(1, 1, n, i, j, 0);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (long long j = 0; j < 60; j++) {
      if (((1LL << j) & a[i]))
        ans = soma_mod(ans, (poten[j] * query(1, 1, n, i + 1, n, j, 0)) % MOD);
      else
        ans = soma_mod(ans, (poten[j] * query(1, 1, n, i + 1, n, j, 1)) % MOD);
    }
  }
  cout << ans << endl;
}
