#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 62;
const int MAX = 510000;
const int V = 100005;
long long dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};
long long dx[8] = {0, 1, 0, -1, 1, -1, -1, 1};
const double pi = acos(-1);
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
inline void print2(T1 a, T2 b) {
  cout << a << " " << b << endl;
}
const int mod = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  vector<long long> bit(60, 0);
  vector<long long> sum(n + 1, 0);
  for (long long i = 0; i < (n); i++) {
    sum[i + 1] = (sum[i] + a[i]) % mod;
    for (long long j = 0; j < (60); j++) {
      if (a[i] < (1 << j)) break;
      if (a[i] & (1 << j)) bit[j]++;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (n - 1); i++) {
    vector<long long> bit2(60, 0);
    for (long long j = 0; j < (60); j++) {
      if (a[i] < (1 << j)) break;
      if (a[i] & (1 << j)) bit[j]--, bit2[j]++;
    }
    long long tmp = (sum[n] - sum[i + 1]) % mod;
    while (tmp < 0) tmp += mod;
    ans += tmp;
    ans %= mod;
    for (long long j = 0; j < (60); j++) {
      if (bit2[j]) {
        long long t = n - i - 1 - bit[j] - bit[j];
        ans += (1 << j) % mod * t % mod;
        while (ans < 0) ans += mod;
        ans %= mod;
      }
    }
  }
  cout << ans % mod << endl;
}
