#include <bits/stdc++.h>
using namespace std;
random_device rd;
mt19937 rnd(rd());
const long long inf = 9223372036854775807LL;
const long long N = 3e5 + 5, mod = 1e9 + 7;
long long a[N][2][61];
long long bp(long long a, long long k) {
  if (k == 0) return 1;
  if (k % 2) return (bp(a, k - 1) * a) % mod;
  long long temp = bp(a, k / 2) % mod;
  return (temp * temp) % mod;
}
signed main() {
  cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<long long> vec(n);
  for (long long i = 0; i < n; ++i) cin >> vec[i];
  for (long long i = n - 1; i > 0; --i) {
    long long first = vec[i], bit = 0;
    while (first) {
      ++a[i][first % 2][bit];
      ++bit;
      first /= 2;
    }
    for (long long j = 0; j < 60; ++j) {
      a[i - 1][0][j] = a[i][0][j];
      a[i - 1][1][j] = a[i][1][j];
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n - 1; ++i) {
    vector<long long> bits(60);
    long long first = vec[i], bit = 0;
    while (first) {
      bits[bit] = first % 2;
      ++bit;
      first /= 2;
    }
    for (long long j = 0; j < 60; ++j) {
      long long temp = a[i + 1][(bits[j] + 1) % 2][j] % mod;
      long long pw = bp(2, j) % mod;
      ans += (pw * temp) % mod;
      ans %= mod;
    }
  }
  cout << ans << '\n';
  for (long long i = 1; i < n; ++i) {
    for (long long j = 0; j < 4; ++j)
      cout << a[i][0][j] << " " << a[i][1][j] << '\n';
    cout << '\n';
  }
  return 0;
}
