#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(numeric_limits<double>::max_digits10);
  solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(61, 0);
  for (int i = (0); i < ((n)); i++) {
    cin >> a[i];
    for (int j = (0); j < ((61)); j++)
      b[j] += ((a[i] & (1LL << j)) == 0 ? 0 : 1);
  }
  ll ans = 0;
  for (int i = (0); i < ((n - 1)); i++) {
    for (int j = (0); j < ((61)); j++)
      if (b[j] > 0) b[j] -= ((a[i] & (1LL << j)) == 0 ? 0 : 1);
    ll x = 0;
    for (int j = (0); j < ((61)); j++) {
      if ((a[i] & (1LL << j)) == 0) {
        x += b[j] * (1LL << j);
      } else {
        x += ((n - i - 1) - b[j]) * (1LL << j);
      }
    }
    ans += x;
    ans %= MOD;
  }
  cout << ans << EOL;
}
