import Foundation

let n = Int(readLine()!)!
let a = readLine()!.split(separator: " ").map { Int($0)! }
var box: [Int] = .init(repeating: 0, count: n + 1)
var count = 0

for i in (1...n).reversed() {
  box[i] = a[i - 1] & 1
  count += box[i]
  if i > n / 2 {
    continue
  }
  var j = i * 2
  var cur = box[i]
  while j <= n {
    cur = cur ^ box[j]
    j += i
  }
  if cur != box[i] {
    count = -1
    break
  }
}
print(count)
if count > 0 {
  for i in 1...count {
    print(box[i], terminator: " ")
  }
}