# oj t -c "python3 main.py" import sys,math from collections import defaultdict,deque from itertools import combinations,permutations,accumulate,product from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify #from sortedcontainers import SortedList,SortedSet def input():return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) inf = pow(10,18) mod = 998244353 #////////////////////////////////// N,M = ms() A = li() A.sort() AS = set(A) ans = list() ok = set() ng = set() def judge(a): for j in range(2,a+1): if a%j!=0: continue if j in ng: continue tmp = j while tmp<=A[-1]: if tmp not in AS: ng.add(j) break tmp += j if j in ng: continue else: tmp = j while tmp<=A[-1]: ok.add(tmp) tmp += j return j return -1 for i in range(1,N): if A[i] in ok: continue res = judge(A[i]) if res==-1: print(-1) exit() ans.append(res) ans.sort() print(len(ans)) print(*ans)