#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;
template <typename T>
T gcd(T a, T b) {
  if (a < b) return gcd(b, a);
  T r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
template <typename T>
T lcm(const T a, const T b) {
  return a / gcd(a, b) * b;
}
char buf[1 << 17], *bp = buf, *bend = buf;
char gc() {
  if (bp == bend) {
    int x = fread(buf, 1, sizeof buf, stdin);
    bend = buf + x;
    bp = buf;
  }
  return *bp++;
}
void readint64(uint64 &n) {
  char c;
  n = 0;
  c = gc();
  for (; '0' <= c && c <= '9'; c = gc()) n = 10 * n + c - '0';
}
int main() {
  constexpr uint64 mod = 1000000007;
  uint64 n;
  readint64(n);
  uint64 ones0[16];
  uint64 ones[64] = {};
  constexpr uint64 mask = (1LL << 0) | (1LL << 16) | (1LL << 32) | (1LL << 48);
  constexpr int n_split = 60000;
  for (int i = 0; i < (int)(5); ++i) {
    memset(ones0, 0, sizeof ones0);
    for (int j = 0; j < (int)(n_split / 2); ++j) {
      uint64 a0;
      uint64 a1;
      readint64(a0);
      readint64(a1);
      for (int k = 0; k < (int)(16); ++k) {
        ones0[k] += a0 & mask;
        ones0[k] += a1 & mask;
        a0 >>= 1;
        a1 >>= 1;
      }
    }
    constexpr uint64 mask16 = (1LL << 16) - 1;
    for (int j = 0; j < (int)(4); ++j)
      for (int k = 0; k < (int)(16); ++k)
        ones[j * 16 + k] += (ones0[k] >> (16 * j)) & mask16;
  }
  uint64 ans = 0;
  for (uint64 bit = 0; bit < 60; ++bit) {
    ans += ((ones[bit] * (n - ones[bit])) % mod) * ((1LL << bit) % mod);
    ans %= mod;
  }
  cout << (ans) << '\n';
  return 0;
}
