#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<unsigned long long> A(N);
  for (auto i = 0; i < N; ++i) {
    cin >> A[i];
  }
  unsigned long long mod = (unsigned long long)1e9 + 7;
  vector<unsigned long long> sum0[60];
  vector<unsigned long long> sum1[60];
  for (auto i = 0; i < 60; ++i) {
    auto bit = (1ull << i);
    auto temp0 = 0ull;
    auto temp1 = 0ull;
    for (auto j = 0; j < N; ++j) {
      temp0 += ~A[j] & bit;
      temp0 %= mod;
      sum0[i].push_back(temp0);
      temp1 += A[j] & bit;
      temp1 %= mod;
      sum1[i].push_back(temp1);
    }
  }
  auto result = 0ull;
  for (auto i = 0; i < N - 1; ++i) {
    for (auto j = 0; j < 60; ++j) {
      auto add = 0ull;
      if ((A[i] & (1ull << j)) == 0) {
        add = sum1[j][N - 1] - sum1[j][i];
      } else {
        add = sum0[j][N - 1] - sum0[j][i];
      }
      result = result + add;
      result %= mod;
    }
  }
  cout << result << endl;
  return 0;
}
