#pragma GCC target "arch=skylake" #pragma GCC optimize "Ofast" #include using namespace std; // TLEするコード int main() { int N, M; cin >> N >> M; vector A(N); for(int i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); vector B; for(int i = 1; i < N; i++) { for(int j = A[i]; j <= M; j += A[i]) { if(!binary_search(A.begin(), A.end(), j)) { cout << -1 << endl; return 0; } } bool ret = true; for(auto a : B) { if(a > (A[i] / 2)) break; if(A[i] % a == 0) ret = false; } if(ret) B.emplace_back(A[i]); } cout << B.size() << endl; for(int i = 0; i < (int)B.size(); i++) { cout << B[i]; if(i != (int)B.size() - 1) cout << ' '; } cout << endl; }