#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, i, j, ds[63] = {};
  long long a[300005], dp[300005];
  const long long mod = 1e9 + 7;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  dp[0] = 0;
  for (i = 0; i < n; i++) {
    int d[63] = {};
    j = 0;
    while (a[i] > 0) {
      d[j] = a[i] % 2;
      a[i] /= 2;
      j++;
    }
    long long o = 1, s = 0;
    dp[0] = 0;
    for (j = 0; j < 60; j++) {
      if (d[j] == 0) {
        s = (s + ds[j] * o % mod) % mod;
      } else {
        s = (s + (i - ds[j]) * o % mod) % mod;
      }
      o *= 2;
    }
    dp[i + 1] = (dp[i] + s) % mod;
    for (j = 0; j < 60; j++) ds[j] += d[j];
  }
  cout << dp[n] << endl;
  return 0;
}
