#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 10;
long long int x[N], p[64], sum1[N], sum0[N];
int main() {
  p[0] = 1;
  for (int i = 1; i < 63; i++) p[i] = (p[i - 1]) * 2ll;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> x[i];
  long long int ans = 0;
  for (int i = 0; i < 63; i++) {
    memset(sum1, 0, sizeof(sum1));
    memset(sum0, 0, sizeof(sum0));
    for (int j = n; j >= 1; j--) {
      sum1[j] = sum1[j + 1];
      sum0[j] = sum0[j + 1];
      if ((x[j] >> i) & 1)
        sum1[j]++;
      else
        sum0[j]++;
      if ((x[j] >> i) & 1) {
        long long int temp = (sum0[j + 1] % mod * p[i] % mod) % mod;
        ans = (ans % mod + temp % mod) % mod;
      } else {
        long long int temp = (sum1[j + 1] % mod * p[i] % mod) % mod;
        ans = (ans % mod + temp % mod) % mod;
      }
    }
  }
  cout << ans % mod << endl;
  return 0;
}
