#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;
int main() {
  constexpr ll mod = inf;
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll>> cnt(n, vector<ll>(63));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < 63; ++j) {
      cnt[i][j] += a[i] >> j & 1;
    }
  }
  for (int j = 0; j < 63; ++j) {
    for (int i = n - 2; i >= 0; --i) {
      cnt[i][j] += cnt[i + 1][j];
    }
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 63; ++j) {
      if (cnt[i][j] == 0) continue;
      if (a[i] >> j & 1) {
        ans += (1LL << j) * (n - i - cnt[i][j]);
      } else {
        ans += (1LL << j) * (cnt[i][j]);
      }
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
