#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ch[300010][63], sum[63] = {0};
  cin >> n;
  for (long long i = 0; i < n; i++) {
    long long now;
    cin >> now;
    long long j = 0;
    while (now != 0) {
      ch[i][j] = now % 2;
      now /= 2;
      j++;
    }
  }
  for (long long i = 0; i < 62; i++) {
    for (long long j = 0; j < n; j++) {
      sum[i] += ch[j][i];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    for (long long j = 0; j < 60; j++) {
      sum[j] = sum[j] - ch[i][j];
    }
    long long cnt = 0;
    long long keta = 1;
    for (long long j = 0; j < 60; j++) {
      if (ch[i][j]) {
        cnt += (n - i - 1 - sum[j]) * keta;
      } else {
        cnt += sum[j] * keta;
      }
      cnt %= 1000000007;
      keta *= 2;
    }
    ans += cnt;
    ans %= 1000000007;
  }
  cout << ans;
  return 0;
}
