#include <bits/stdc++.h>
template <int Mod>
class ModInt {
 public:
  ModInt() : n_(0) {}
  ModInt(long long n) : n_(n % Mod) {
    if (n_ < 0) {
      n_ += Mod;
    }
  }
  ModInt& operator+=(const ModInt& m) {
    n_ += m.n_;
    if (n_ >= Mod) {
      n_ -= Mod;
    }
    return *this;
  }
  ModInt& operator++() { return (*this) += 1; }
  ModInt& operator-=(const ModInt& m) {
    n_ -= m.n_;
    if (n_ < 0) {
      n_ += Mod;
    }
    return *this;
  }
  ModInt& operator--() { return (*this) -= 1; }
  ModInt& operator*=(const ModInt& m) {
    n_ *= m.n_;
    n_ %= Mod;
    return *this;
  }
  ModInt& operator/=(const ModInt& m) {
    *this *= m.inverse();
    return *this;
  }
  ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
  ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
  ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
  ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
  bool operator!=(const ModInt& m) const { return n_ != m.n_; }
  bool operator<(const ModInt& m) const { return n_ < m.n_; }
  bool operator<=(const ModInt& m) const { return n_ <= m.n_; }
  bool operator==(const ModInt& m) const { return n_ == m.n_; }
  bool operator>(const ModInt& m) const { return n_ > m.n_; }
  bool operator>=(const ModInt& m) const { return n_ >= m.n_; }
  ModInt pow(int n) const {
    if (n < 0) {
      return inverse().pow(-n);
    }
    ModInt a = 1, b = *this;
    while (n != 0) {
      if (n & 1) {
        a *= b;
      }
      n /= 2;
      b *= b;
    }
    return a;
  }
  ModInt inverse() const { return pow(Mod - 2); }
  long long value() const { return n_; }
  static ModInt factorial(int n) {
    for (int i = factorial_.size(); i <= n; ++i) {
      factorial_.push_back(i == 0 ? 1 : factorial_.back() * i);
    }
    return factorial_[n];
  }
  static ModInt combination(int n, int k) {
    return factorial(n) / factorial(n - k) / factorial(k);
  }
  static ModInt combination_slow(int n, int k) {
    ModInt numerator = 1;
    for (int i = 0; i < k; ++i) {
      numerator *= (n - i);
    }
    return numerator / factorial(k);
  }

 private:
  long long n_;
  static std::vector<ModInt> factorial_;
};
template <int Mod>
std::vector<ModInt<Mod>> ModInt<Mod>::factorial_;
template <int Mod>
std::ostream& operator<<(std::ostream& out, const ModInt<Mod>& m) {
  out << m.value();
  return out;
}
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 mint = ModInt<int(1e9 + 7)>;
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);
  mint 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;
    for (int j = 0; j < 60; ++j) {
      ll bit = (a[i] >> j) & 1;
      sum[j] += bit;
      xsum[j] += 1 - bit;
    }
  }
  write_to_cout(ans);
  ;
}
