#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<bool> to_bin(long long x) {
  vector<bool> res(60, 0);
  long long cur = (1LL << 59LL);
  int cnt = 59;
  while (cur) {
    if (x >= cur) {
      x -= cur;
      res[cnt] = 1;
    }
    cur >>= 1;
    --cnt;
  }
  return res;
}
signed main() {
  int n;
  cin >> n;
  vector<vector<bool> > a(n);
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a[i] = to_bin(x);
  }
  vector<vector<vector<long long> > > pref(
      2, vector<vector<long long> >(n + 1, vector<long long>(60, 0LL)));
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 60; ++j) {
      pref[0][i + 1][j] = pref[0][i][j];
      pref[1][i + 1][j] = pref[1][i][j];
    }
    for (long long j = 0; j < 60; ++j) {
      (ans += ((pref[!a[i][j]][i][j] * (1LL << j)) % mod)) %= mod;
      ++pref[a[i][j]][i + 1][j];
    }
  }
  cout << ans << '\n';
}
