#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 1];
  int b[n + 1];
  a[0] = 0;
  b[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    b[i + 1] = 0;
  }
  int sum;
  bool exist = false;
  for (int i = n; i > 0; i--) {
    sum = 0;
    for (int j = i; j <= n; j += i) {
      sum = sum ^ a[i];
    }
    if (sum) {
      exist = true;
    }
    b[i] = sum;
  }
  if (exist) {
    cout << n << endl;
    for (int i = 1; i <= n; i++) {
      cout << b[i] << " ";
    }
  } else {
    cout << 0 << endl;
  }
  return 0;
}
