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