#include <bits/stdc++.h>
using namespace std;
const long long maxn = 300005, mod = 1e9 + 7;
long long n, tong0, tong1, ans, mi[maxn], a[maxn];
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
inline void write(long long a) {
  if (a < 0) {
    char a = '-', b = '1';
    putchar(a);
    putchar(b);
  } else {
    if (a >= 10) write(a / 10);
    putchar(a % 10 + '0');
  }
}
signed main() {
  n = read();
  mi[0] = 1;
  for (long long i = 1; i <= 62; ++i) mi[i] = pow(2, i);
  for (long long i = 1; i <= n; ++i) a[i] = read();
  for (long long i = 0; i <= 62; ++i) {
    tong1 = tong0 = 0;
    for (long long j = 1; j <= n; ++j) {
      if (a[j] & 1) {
        ans = (ans + tong0 * mi[i] % mod) % mod;
        ++tong1;
      } else {
        ans = (ans + tong1 * mi[i] % mod) % mod;
        ++tong0;
      }
      a[j] >>= 1;
    }
  }
  write(ans);
  return 0;
}
