#include <bits/stdc++.h>
void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
using ll = long long;
using namespace std;
int main() {
  int n;
  read_from_cin(n);
  ;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  vector<ll> sum(61);
  vector<ll> xsum(61);
  ll ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    ll x = 0;
    for (int j = 0; j < 60; ++j) {
      ll n = 0;
      if ((a[i] >> j) & 1) {
        n = xsum[j];
      } else {
        n = sum[j];
      }
      x += n << j;
    }
    ans += x;
    ans %= int(1e9 + 7);
    for (int j = 0; j < 60; ++j) {
      ll bit = (a[i] >> j) & 1;
      sum[j] += bit;
      xsum[j] += 1 - bit;
    }
  }
  write_to_cout(ans);
  ;
}
