#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 3e5 + 5, M = 61;
const ll MOD = 1e9 + 7;
ll A[N];
int suff[M][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  for (int i = n - 1; i >= 1; --i) {
    for (int j = 0; j < M; ++j) {
      suff[j][i] = suff[j][i + 1];
      if ((A[i + 1] >> j) & 1LL) ++suff[j][i];
    }
  }
  vector<int> cur(M, 0);
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    fill(cur.begin(), cur.end(), 0);
    for (int j = 0; j < M; ++j) {
      if ((A[i] >> j) & 1LL)
        cur[j] += (n - i - suff[j][i]);
      else
        cur[j] += suff[j][i];
    }
    ll p = 1;
    for (int j = 0; j < M; ++j) {
      ans += (p * cur[j]);
      ans %= MOD;
      p <<= 1;
    }
  }
  cout << ans << "\n";
}
