#include <bits/stdc++.h>
using namespace std;
using pii = pair<int64_t, int64_t>;
constexpr int64_t INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod = 1e9 + 7;
template <class A, class B>
inline bool chmax(A &a, const B &b) {
  return b > a && (a = b, true);
}
template <class A, class B>
inline bool chmin(A &a, const B &b) {
  return b < a && (a = b, true);
}
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
template <class T>
using max_heap = priority_queue<T>;
int64_t gcd(int64_t a, int64_t b) { return b ? gcd(b, a % b) : a; }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64_t n;
  cin >> n;
  vector<int64_t> a(n + 1);
  vector<vector<int64_t> > cnt(n + 1, vector<int64_t>(70));
  for (int64_t i = 1; i <= (n); ++i) {
    cin >> a[i];
    int64_t tmp = a[i];
    for (int64_t j = 0; j < 62; ++j) {
      cnt[i][j] = cnt[i - 1][j] + (tmp % 2 == 1);
      cnt[i][j];
      tmp >>= 1;
    }
  }
  int64_t sum = 0;
  for (int64_t i = 1; i < n; ++i) {
    for (int64_t j = 0; j < (61); ++j) {
      int64_t tmp = cnt[n][j] - cnt[i][j];
      if (a[i] & (1ll << j)) {
        (sum += ((n - i) - tmp) * (1ll << j)) %= mod;
      } else {
        (sum += tmp * (1ll << j)) %= mod;
      }
    }
  }
  cout << sum << '\n';
  return 0;
}
