#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const long long mod = 1e9 + 7;
long long fastpow(long long a, long long b) {
  if (b == 0) return 1;
  if (b & 1) return fastpow(a, b - 1) * a % mod;
  long long t = fastpow(a, b / 2);
  return t * t % mod;
}
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  long long suf[n][60];
  memset(suf, 0, sizeof(suf));
  for (long long i = n - 1; i >= 0; --i) {
    for (long long j = 0; j < 60; ++j) {
      if ((1LL << j) & a[i]) suf[i][j] = 1;
    }
    if (i != n - 1) {
      for (long long j = 0; j < 60; ++j) {
        suf[i][j] += suf[i + 1][j];
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; ++i) {
    for (long long j = 0; j < 60; ++j) {
      if (a[i] & (1LL << j)) {
        ans += (1LL << j) * (n - i - 1 - suf[i + 1][j]);
      } else {
        ans += (1LL << j) * suf[i + 1][j];
      }
      ans %= mod;
    }
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
