#include <bits/stdc++.h>
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psl = pair<string, ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const ll MOD = (ll)1e9 + 7;
  int N;
  cin >> N;
  vl A(N);
  for (int i = int(0); i < int(N); ++i) cin >> A[i];
  vvi h(N, vi(60, 0));
  ll mask = 0b01;
  for (int b = int(0); b < int(60); ++b) {
    if (A[0] & mask) h[0][b] = 1;
    mask <<= 1;
  }
  for (int i = int(1); i < int(N); ++i) {
    ll a = A[i];
    ll mask = 0b01;
    for (int b = int(0); b < int(60); ++b) {
      if (a & mask)
        h[i][b] = h[i - 1][b] + 1;
      else
        h[i][b] = h[i - 1][b];
      mask <<= 1;
    }
  }
  ll ans = 0;
  mask = 0b01;
  int carry = 0;
  for (int b = int(0); b < int(60); ++b) {
    int cnt = 0;
    for (int i = int(1); i < int(N); ++i) {
      int one = h[N - 1][b] - h[i - 1][b];
      int zero = (N - 1 - i + 1) - one;
      if (A[i - 1] & mask)
        cnt += zero;
      else
        cnt += one;
    }
    if ((carry + cnt) % 2 == 1) ans = ans | mask;
    carry = (carry + cnt) / 2;
    mask <<= 1;
  }
  ans = ans & 0x0FFFFFFFFFFFFFFF;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}
