#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, s[60], t[60], MOD = 1e9 + 7, ans;
int main(void) {
  cin >> n;
  cin >> a;
  for (int i = 0; i < 60; i++) {
    if (((a >> i) & 1) == 1) {
      s[i]++;
    }
  }
  for (int j = 1; j < n; j++) {
    cin >> a;
    for (long long i = 0; i < 60; i++) {
      if (((a >> i) & 1) == 1) {
        ans += (j - s[i]) * (1LL << i);
        s[i]++;
      } else {
        ans += s[i] * (1LL << i);
      }
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
