#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, inf = 0x3f3f3f3f, maxn = 3e5 + 5;
long long n, m, Q, K;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * f;
}
long long a[maxn], ton[70];
long long ans = 0;
long long mmax(long long x, long long y) {
  if (x >= y) return x;
  return y;
}
signed main() {
  n = read();
  long long maxs = 0;
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    maxs = max(maxs, a[i]);
  }
  for (long long i = n; i >= 1; --i) {
    for (long long j = 0; (1ll << j) <= maxs; ++j) {
      if (((a[i] >> j) & 1) == 0)
        ans = (ans + (1ll << j) * ton[j]) % mod;
      else
        ans = (ans + (1ll << j) * mmax(0, (n - i - ton[j]))) % mod;
    }
    for (long long j = 0; (1ll << j) <= maxs; ++j) {
      ton[j] += ((a[i] >> j) & 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
