#include <iostream>
#include <string.h>
using namespace std;

bool prime[1000001];
void is_prime(int n){
	for(int i = 0; i <= n; ++i)
		prime[i] = true;
	prime[0] = prime[1] = false;
	
	for(int i = 2; i <= n; ++i){
		if(prime[i]){
			for(int j = i * 2; j <= n; j += i)
				prime[j] = false;
		}
	}
}

int memo[1000001];
int N, X, cook[50], ans;

int rec(int w){
	if(memo[w] != -1)
		return memo[w];
	if(prime[X - w])
		ans = max(ans, X - w);
	int res = 0;
	for(int i = 0; i < N; ++i){
		if(w - cook[i] >= 0)
			res = max(res, rec(w - cook[i]));
	}
	return memo[w] = res;
}

int main() {
	is_prime(1000000);
	while(cin >> N >> X && (N || X)){
		ans = 0;
		memset(memo, -1, sizeof(memo));
		
		for(int i = 0; i < N; ++i)
			cin >> cook[i];
			
		rec(X);
		if(ans == 0)
			cout << "NA" << endl;
		else
			cout << ans << endl;
	}
	
	
	return 0;
}