#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A.at(i);
  vector<vector<int>> sum0(N, vector<int>(60, 0)), sum1(N, vector<int>(60, 0));
  for (int i = 0; i < (int)(N); i++) {
    for (int j = 0; j < (int)(60); j++) {
      if (i == 0) {
        if (A.at(i) & (1LL << j))
          sum1.at(i).at(j) = 1;
        else
          sum0.at(i).at(j) = 1;
      } else {
        if (A.at(i) & (1LL << j)) {
          sum0.at(i).at(j) = sum0.at(i - 1).at(j);
          sum1.at(i).at(j) = sum1.at(i - 1).at(j) + 1;
        } else {
          sum0.at(i).at(j) = sum0.at(i - 1).at(j) + 1;
          sum1.at(i).at(j) = sum1.at(i - 1).at(j);
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < (int)(60); i++) {
    ll tmp = 0;
    for (int j = 0; j < (int)(N - 1); j++) {
      if (A.at(j) & (1LL << i))
        tmp += sum0.at(N - 1).at(i) - sum0.at(j).at(i);
      else
        tmp += sum1.at(N - 1).at(i) - sum1.at(j).at(i);
    }
    ans = ((ll)pow(2, i) % MOD * tmp % MOD + ans) % MOD;
  }
  cout << ans << endl;
}
