#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
const long long MOD = 1000000007;
const long long MAX = 10010010010;
int main() {
  int n;
  cin >> n;
  long long x[n];
  int cnt1[n][70];
  for (int i = 0; i < (n); i++) {
    cin >> x[i];
    for (long long j = 0; j < 60; j++) {
      if (i == 0)
        cnt1[i][j] = 0;
      else
        cnt1[i][j] = cnt1[i - 1][j];
      if (x[i] >= (long long)(1ull << j) &&
          (long long)x[i] & (long long)(1ull << j)) {
        cnt1[i][j]++;
      }
    }
  }
  long long sum[n];
  sum[1] = (x[0] ^ x[1]) % MOD;
  if (n == 2) {
    cout << sum[1] << endl;
    return 0;
  }
  for (int i = 2; i < n; i++) {
    long long res = 0;
    for (long long j = 0; j < 60; j++) {
      if (x[i] & (long long)(1ull << j))
        res += (1ull << j) * (i - cnt1[i - 1][j]);
      else
        res += (1ull << j) * (cnt1[i - 1][j]);
      res %= MOD;
    }
    sum[i] = sum[i - 1] + res;
    sum[i] %= MOD;
  }
  cout << sum[n - 1] << endl;
}
