require'prime'
t={}
Prime.each(1e6){|i|t[i]=true}
while(n,x=gets.split.map &:to_i)[0]>0
d=[m=0]
c=(1..n).map{gets.to_i}
(i=d.pop
m<i&&t[i]&&m=i
c.map{|j|j+=i;x<j||(l=d.rindex{|k|k>=j}||-1;d[l]!=j&&d[l+1,0]=[j])})while d[0]
puts m<1?:NA:m
end