#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;
int main() {
  int n;
  cin >> n;
  vector<unsigned long long> a(n, 0);
  for (int i = 0, i_len = (n); i < i_len; ++i) {
    cin >> a[i];
  }
  vector<v> memo(60, v(n, 0));
  unsigned long long compare = 1;
  for (int i = 0, i_len = (60); i < i_len; ++i) {
    for (int j = 0, j_len = (n); j < j_len; ++j) {
      if (j == 0) {
        if (compare & a[j]) {
          memo[i][j] = 1;
        }
      } else {
        memo[i][j] = memo[i][j - 1];
        if (compare & a[j]) {
          memo[i][j] = memo[i][j - 1] + 1;
        }
      }
    }
    compare = compare << 1;
  }
  ll result = 0;
  ll mod = 1e9 + 7;
  compare = 1;
  for (int i = 0, i_len = (60); i < i_len; ++i) {
    for (int j = 0, j_len = (n); j < j_len; ++j) {
      int count = memo[i][n - 1] - memo[i][j];
      if (compare & a[j]) {
        count = (n - j - 1) - count;
      }
      ll temp = (count * compare) % mod;
      result = (result + temp) % mod;
    }
    compare = compare << 1;
  }
  cout << result << endl;
}
