#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){ if(a<b){ a=b;return true; }return false; }

deque<bool> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	is_prime[0]=is_prime[1]=false;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return is_prime;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto P = enum_prime(1000000);

	while(true){
		int N=in(),X=in();
		if(!N && !X) break;
		auto V=vecin(N);
		vector<int> dp(X+1,0);
		dp[0]=1;
		int ans=-1;
		REP(j,X+1){
			REP(i,N){
				if(j+V[i]<=X){
					chmax(dp[j+V[i]],dp[j]);
				}
			}
			if(dp[j] && P[j]){
				ans = j;
			}
		}
		
		if(ans<0) out("NA");
		else out(ans);
	}

	return 0;
}

