#include <bits/stdc++.h>
long long a[300000];
int main() {
  int n;
  long long sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < 60; i++) {
    int c0 = 0, c1 = 0;
    for (int j = n - 1; j >= 0; j--) {
      if ((a[j] >> i) & 1) {
        sum += (1LL << i) * c0;
        c1++;
      } else {
        sum += (1LL << i) * c1;
        c0++;
      }
      sum %= 1000000007;
    }
  }
  printf("%lld\n", sum);
  return 0;
}
