#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) {
    fread_unlocked(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline long long getint() {
  long long A = 0;
  if (ci - cn + 24 > cm)
    while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else
    while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}
int main() {
  int N = getint();
  long long kazu[20] = {};
  const int mod = 1e9 + 7;
  const long long m = 1 + (1 << 20) + (1ll << 40);
  for (int i = 0; i < ((N + 1) / 2); i++) {
    long long a = getint();
    long long b = getint();
    for (int j = 0; j < (20); j++) {
      kazu[j] += a >> j & m;
      kazu[j] += b >> j & m;
    }
  }
  long long kotae = 0;
  const long long m2 = (1 << 20) - 1;
  for (int j = 0; j < (20); j++) {
    long long tmp = (1ll << j) % mod;
    long long tmpk = (kazu[j] & m2);
    tmpk = tmpk * (N - tmpk) % mod;
    kotae += tmp * tmpk % mod;
    tmp = (1ll << (j + 20)) % mod;
    tmpk = (kazu[j] >> 20 & m2);
    tmpk = tmpk * (N - tmpk) % mod;
    kotae += tmp * tmpk % mod;
    tmp = (1ll << (j + 40)) % mod;
    tmpk = (kazu[j] >> 40 & m2);
    tmpk = tmpk * (N - tmpk) % mod;
    kotae += tmp * tmpk % mod;
  }
  printf("%lld", kotae % mod);
  return 0;
}
