#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1e9;
const long long INFLL = 1e18;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
class modint {
 public:
  using long long = long long;
  long long num;
  static const long long MOD = 1e9 + 7;
  static vector<modint> factorial;
  modint() : num(0){};
  modint(long long num_) : num((num_ + MOD) % MOD) { assert(num >= 0); }
  modint(const modint &r) : num(r.num) {}
  operator long long() const { return num; }
  template <typename T>
  void check_type(const T &num_) const {
    assert(num_ >= 0 && num_ < MOD);
    static_assert(is_integral<T>() || is_same<T, modint>(),
                  "T is not integral.");
  }
  template <typename T>
  modint operator+(const T &r) const {
    check_type(r);
    return num + r;
  }
  template <typename T>
  modint operator-(const T &r) const {
    check_type(r);
    return num - r;
  }
  template <typename T>
  modint operator*(const T &r) const {
    check_type(r);
    return num * r;
  }
  template <typename T>
  modint operator/(const T &r) const {
    check_type(r);
    return num * pow(r, MOD - 2);
  }
  template <typename T>
  modint operator+=(const T &r) {
    return *this = *this + r;
  }
  template <typename T>
  modint operator-=(const T &r) {
    return *this = *this - r;
  }
  template <typename T>
  modint operator*=(const T &r) {
    return *this = *this * r;
  }
  template <typename T>
  modint operator/=(const T &r) {
    return *this = *this / r;
  }
  static modint pow(const modint &x, const long long &r) {
    if (r == 0) return 1;
    return pow(x * x, r / 2) * modint(r & 1 ? x : modint(1));
  }
  static modint fact(int n) {
    if ((int)factorial.size() <= n) {
      int size = factorial.size();
      factorial.resize(n + 1);
      for (int k = size; k <= n; k++) {
        factorial[k] = factorial[k - 1] * k;
      }
    }
    return factorial[n];
  }
  static modint C(int n, int r) {
    return n >= r ? fact(n) / (fact(n - r) * fact(r)) : modint(0);
  }
  friend istream &operator>>(istream &is, modint &r) {
    long long num_;
    is >> num_;
    r = num_;
    return is;
  }
};
vector<modint> modint::factorial = {1};
long long modpow(long long a, long long n, int mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < int(N); ++i) cin >> A[i];
  modint ans = 0;
  vector<vector<int>> cum(60, vector<int>(N + 1, 0));
  for (int k = 0; k < int(60); ++k)
    for (int i = 0; i < int(N); ++i) {
      if (A[i] & (1LL << (k))) {
        cum[k][i + 1] += cum[k][i] + 1;
      } else {
        cum[k][i + 1] = cum[k][i];
      }
    }
  for (int k = 0; k < int(60); ++k)
    for (int i = 0; i < int(N - 1); ++i) {
      int cnt_bit = cum[k][N] - cum[k][i + 1];
      int cnt_zer = N - 1 - i - cnt_bit;
      if (A[i] & (1LL << (k))) {
        ans += modpow(2, k, MOD) * cnt_zer;
      } else {
        ans += modpow(2, k, MOD) * cnt_bit;
      }
    }
  cout << ans << endl;
}
