#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<vector<ll>> sum(n + 1, vector<ll>(61));
  for (int i = n - 1; i >= 1; i--) {
    for (int j = 0; j < 61; j++) {
      sum.at(i).at(j) += sum.at(i + 1).at(j);
      if (a.at(i) & (1ll << j)) sum.at(i).at(j)++;
    }
  }
  ll res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 61; j++) {
      if (a.at(i) & (1ll << j)) {
        res += ((n - i - 1) - sum.at(i + 1).at(j)) << j;
      } else {
        res += sum.at(i + 1).at(j) << j;
      }
      res %= MOD;
    }
  }
  cout << res << endl;
}
