#include <bits/stdc++.h>
using namespace std;
long long n, p = 1e9 + 7, ans, f[300300], pre[300300][62][2];
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &f[i]);
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= 60; j++) {
      long long x = (f[i] >> j);
      if (x & (long long)1)
        pre[i][j][1] = pre[i - 1][j][1] + 1, pre[i][j][0] = pre[i - 1][j][0];
      else
        pre[i][j][1] = pre[i - 1][j][1], pre[i][j][0] = pre[i - 1][j][0] + 1;
    }
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= 60; j++) {
      long long x = (f[i] >> j);
      if (x & (long long)1)
        ans =
            (ans + (pre[n][j][0] - pre[i][j][0]) * ((long long)1 << j) % p) % p;
      else
        ans =
            (ans + (pre[n][j][1] - pre[i][j][1]) * ((long long)1 << j) % p) % p;
    }
  printf("%lld", ans % p);
  return 0;
}
