#include <bits/stdc++.h>
int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}
int fget_array(int64_t *arr, int size) {
  int i;
  for (i = 0; i < size; i++) {
    scanf("%lld", &arr[i]);
  }
  return 0;
}
int main(void) {
  int num = get_int();
  int64_t arr[300000];
  static int cum[300000 + 1][60 + 1];
  fget_array(arr, num);
  int i, bit;
  for (i = num - 1; i >= 0; i--) {
    for (bit = 0; bit <= 60; bit++) {
      if (!(arr[i] & (1LL << bit))) continue;
      cum[bit][i]++;
    }
    for (bit = 0; bit <= 60; bit++) {
      cum[bit][i] += cum[bit][i + 1];
    }
  }
  static int bit_sum[60 + 1];
  for (i = 0; i < num - 1; i++) {
    for (bit = 0; bit <= 60; bit++) {
      if (!(arr[i] & (1LL << bit))) {
        bit_sum[bit] += cum[bit][i + 1];
      } else {
        bit_sum[bit] += ((num - i - 1) - cum[bit][i + 1]);
      }
    }
  }
  int64_t ans = 0;
  int64_t power2 = 1;
  for (i = 0; i <= 60; i++) {
    ans = (ans + power2 * bit_sum[i]) % 1000000007;
    power2 = (power2 * 2) % 1000000007;
  }
  printf("%d\n", (int)ans);
  return 0;
}
