#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;
int n;
long long a[maxn];
int cnt[maxn][60], sum[maxn][60];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int j = 0; j < 60; j++) {
      cnt[i][j] = ((a[i] >> j) & 1ll);
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 60; ++i) {
    for (int j = n - 1; j >= 0; --j) {
      sum[j][i] = sum[j + 1][i] + cnt[j + 1][i];
    }
    for (int j = 0; j < n - 1; ++j) {
      if (cnt[j][i] == 0) {
        ans = (ans + (1ll * sum[j][i] * (1ll << i) % mod) % mod) % mod;
      } else {
        ans = (ans + (1ll * (n - sum[j][i] - 1 - j) * (1ll << i) % mod) % mod) %
              mod;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
