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