require 'prime'

MAX = 1_000_000
ps=[]
(Prime.new).each(MAX){|i| ps.unshift(i)}
loop{
  n,x = gets.split.map(&:to_i)
  break if(n|x) == 0
  m = Array.new(n)
  n.times{|i|
    m[i] = gets.to_i
  }
  b = Array.new(x+1,nil)
  b[0]=true
  (1..x).each{|i|
    (0...n).each{|j|
      b[i]= i-m[j]>=0 && b[i-m[j]]
      break if b[i]
    }
  }
ps.select{|i| i<=x}.each{|i|
    if b[i]
      puts i
      break
    end
    puts "NA" if i==2
  }
}