#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
constexpr i64 MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<i64> v;
  for (int i = 0; i < n; ++i) {
    i64 a;
    cin >> a;
    v.push_back(a);
  }
  vector<vector<i64>> cumsum(60, vector<i64>(n + 1));
  for (int i = 0; i < 60; ++i) {
    for (int j = 1; j <= n; ++j) {
      cumsum[i][j] = cumsum[i][j - 1] + ((v[j - 1] >> i) & 1);
    }
  }
  i64 ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    i64 c = 0, tmp = 0;
    for (int j = 0; j < 60; ++j) {
      i64 d = cumsum[j][n] - cumsum[j][i + 1];
      if ((v[i] >> j) & 1) d = (n - i - 1) - d;
      d += c;
      tmp |= ((d & 1) << j);
      c = d / 2;
    }
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
