#include <bits/stdc++.h>
void tobi(long long num, long long *a);
int power(int m, int n);
int main(void) {
  long long n, m, a[300000], i, j, counter[60] = {0}, value[60], nowbi[60], row,
                                   ans = 0;
  scanf("%lld", &n);
  for (i = 0; i < n; i++) {
    scanf("%lld", a + i);
  }
  for (i = 0; i < n; i++) {
    tobi(a[i], nowbi);
    for (j = 0; j < 60; j++) {
      counter[j] += nowbi[j];
    }
  }
  for (i = 0; i < n - 1; i++) {
    m = n - i - 1;
    tobi(a[i], nowbi);
    for (j = 0; j < 60; j++) {
      counter[j] -= nowbi[j];
    }
    for (j = 0; j < 60; j++) {
      if (nowbi[j] == 1) {
        value[j] = m - counter[j];
      } else {
        value[j] = counter[j];
      }
    }
    row = 0;
    for (j = 0; j < 60; j++) {
      row += value[j] * (power(2, j) % (power(10, 9) + 7));
    }
    ans += row % (power(10, 9) + 7);
  }
  printf("%d", ans % (power(10, 9) + 7));
  return 0;
}
void tobi(long long num, long long *a) {
  for (int i = 0; i < 60; i++) {
    a[i] = (num >> i) & 1;
  }
}
int power(int m, int n) {
  int p = 1;
  for (int i = 0; i < n; i++) p *= m;
  return p;
}
