#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
struct mint {
  unsigned x;
  mint() : x(0) {}
  mint(signed sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }
  mint(signed long long sig) { x = sig < 0 ? sig % mod + mod : sig % mod; }
  long long get() const { return (long long)x; }
  mint& operator+=(mint that) {
    if ((x += that.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(mint that) {
    if ((x += mod - that.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(mint that) {
    x = (unsigned long long)x * that.x % mod;
    return *this;
  }
  mint& operator/=(mint that) { return *this *= that.inverse(); }
  mint operator+(mint that) const { return mint(*this) += that; }
  mint operator-(mint that) const { return mint(*this) -= that; }
  mint operator*(mint that) const { return mint(*this) *= that; }
  mint operator/(mint that) const { return mint(*this) /= that; }
  mint inverse() const {
    long long a = x, b = mod, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    return mint(u);
  }
  bool operator==(mint that) const { return x == that.x; }
  bool operator!=(mint that) const { return x != that.x; }
  mint operator-() const {
    mint t;
    t.x = x == 0 ? 0 : mod - x;
    return t;
  }
};
class DXorSum4 {
 public:
  static constexpr long long kStressIterations = 0;
  static void generateTest(std::ostream& test) {}
  void solve(std::istream& cin, std::ostream& cout) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0, i_len = (n); i < i_len; ++i) cin >> a[i];
    vector<vector<long long>> sum(65, vector<long long>(n, 0));
    for (long long i = 0, i_len = (65); i < i_len; ++i) {
      for (long long j = 0, j_len = (n); j < j_len; ++j) {
        if (a[j] >> i & 1) sum[i][j]++;
      }
    }
    for (long long i = 0, i_len = (65); i < i_len; ++i) {
      for (long long j = (1), j_len = (n - 1); j <= j_len; ++j) {
        sum[i][j] += sum[i][j - 1];
      }
    }
    mint res = 0;
    for (long long i = 0, i_len = (61); i < i_len; ++i) {
      for (long long j = 0, j_len = (n - 1); j < j_len; ++j) {
        long long num = sum[i][n - 1] - sum[i][j];
        long long rem = n - (j + 1) - num;
        if (a[j] >> i & 1) {
          res += (1LL << i) * rem;
        } else {
          res += (1LL << i) * num;
        }
      }
    }
    cout << res.get() << endl;
  }
};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  DXorSum4 solver;
  solver.solve(in, out);
  return 0;
}
