#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class in {
  int n;

 public:
  in() {}
  in(int n_) : n(n_){};
  template <class T>
  operator T() {
    T ret;
    cin >> ret;
    return ret;
  }
  template <class T>
  operator vector<T>() {
    vector<T> ret(n);
    for (int i = 0; i < n; i++) cin >> ret[i];
    return ret;
  }
};
template <std::uint_fast64_t Mod>
class modint {
  using u64 = std::uint_fast64_t;
  u64 a;
  friend ostream& operator<<(ostream& os, const modint& m);

 public:
  constexpr modint(const u64 x = 0) noexcept : a(x % Mod) {}
  constexpr u64 val() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return modint(*this).val() == rhs.val();
  }
  modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Mod) a -= Mod;
    return *this;
  }
  modint& operator-=(const modint rhs) noexcept {
    if (a < rhs.a) a += Mod;
    a -= rhs.a;
    return *this;
  }
  modint& operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Mod;
    return *this;
  }
  modint& operator/=(modint rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
const ll mod = (ll)1e9 + 7;
using mint = modint<mod>;
ostream& operator<<(ostream& os, const mint& m) { return os << m.a; }
const int kMaxBit = 64;
int bit[kMaxBit];
int main() {
  int N = in();
  vector<ll> A = in(N);
  mint ans = 0;
  for (int i = (int)(0), i_end = (int)(N); i < i_end; ++i) {
    for (int b = (int)(0), b_end = (int)(kMaxBit); b < b_end; ++b) {
      bit[b] += ((A[i] >> b) & 1);
    }
  }
  for (int i = (int)(0), i_end = (int)(N); i < i_end; ++i) {
    for (int b = (int)(0), b_end = (int)(kMaxBit); b < b_end; ++b) {
      if (((A[i] >> b) & 1)) {
        ans += ((N - i - bit[b]) * (1LL << b));
        bit[b]--;
      } else {
        ans += (bit[b] * (1LL << b));
      }
    }
  }
  cout << ans << endl;
  return 0;
}
