require 'prime'

loop do
    n, budget = gets.split.map &:to_i
    break if n == 0
    dish = (1..n).map { gets.to_i }

    table = [false] * (budget+1)
    table[0] = true
    (1..budget).each do |x|
        dish.each do |d|
            (table[x] =  (d <= x && table[x-d])) && break
        end
    end
    
    candidates = (2..budget).select {|i| table[i]}.reverse
    puts candidates.find{|x| Prime.prime?(x)} || 'NA'
end