#include <bits/stdc++.h>
using namespace std;
int main() {
  constexpr int64_t MOD = (int64_t)1e9 + 7;
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; i++) {
    cin >> A[i];
  }
  constexpr int64_t MAX = 61;
  vector<vector<int64_t>> d_num(61, vector<int64_t>(N + 1, 0));
  for (int64_t i = 0; i < 61; i++) {
    for (int64_t j = 0; j < N; j++) {
      d_num[i][j + 1] = d_num[i][j] + (bool)(A[j] & (1LL << i));
    }
  }
  int64_t ans = 0;
  for (int64_t i = 1; i < N; i++) {
    int64_t carry_over = 0;
    for (int64_t j = 0; j < MAX; j++) {
      int64_t num = d_num[j][i];
      if (A[i] & (1LL << j)) {
        num = i - num;
      }
      (ans += num * (1LL << j)) %= MOD;
    }
  }
  cout << ans << endl;
}
