#include <bits/stdc++.h>
long a[300010], s[64][300010][2];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%ld", a + i);
    for (int j = 0; j < 61; ++j) {
      int k = (a[i] >> j) & 1;
      if (k == 0) {
        s[j][i + 1][0] = s[j][i][0] + 1;
        s[j][i + 1][1] = s[j][i][1];
      } else {
        s[j][i + 1][0] = s[j][i][0];
        s[j][i + 1][1] = s[j][i][1] + 1;
      }
    }
  }
  const long mod = 1e9 + 7;
  long res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 61; ++j) {
      int x = (a[i] >> j) & 1;
      long t = s[j][n][!x] - s[j][i][!x];
      t *= (1L << j) % mod;
      while (t >= mod) t -= mod;
      res += t;
      if (res >= mod) res -= mod;
    }
  }
  printf("%ld\n", res);
}
