#include <bits/stdc++.h>
using namespace std;
long long N, A[303030];
long long mk[66];
long long i, j, k, ans;
int main() {
  scanf("%lld", &N);
  for (i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < 61; j++) {
      if (A[i] & (1ll << j)) {
        ans = (ans + (i - mk[j]) * (1ll << j)) % (long long)(1e9 + 7);
        mk[j]++;
      } else {
        ans = (ans + mk[j] * (1ll << j)) % (long long)(1e9 + 7);
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
