require "prime"

loop do
  n,m = gets.split.map(&:to_i)
  break if n == 0 and m == 0

  dp = Hash.new(false)
  dp[0] = true

  n.times do
    i = gets.to_i
    (0...m).each{|j| dp[j+i] = dp[j] && true}
  end
  puts(dp.select{|a,b| b}.map(&:first).sort.reverse.find{|x| Prime.prime? x} || "NA")
end