#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
const int MAX = 1000000;
bool prime[1000001];
bool dp[31][1000001];

void Init(){
	for(int i = 0; i <= 30; i++){
		memset(dp[i], false, sizeof(dp[i]));
		dp[i][0] = true;
	}
}

void era(){
	prime[0] = prime[1] = false;
	for(int i = 2; i <= MAX; i++){
		if(prime[i]){
			for(int j = i*2; j <= MAX; j+=i) prime[j] = false;
		}
	}
}

int main(){
	int n, limit;
	memset(prime, true, sizeof(prime));
	era();
	while(cin >> n >> limit && ((n!=0)||(limit!=0))){
		Init();
		for(int i = 1; i <= n; i++){
			int tmp;
			cin >> tmp;
			int money = tmp;
			while(money <= limit){
				dp[i][money] = true;
				for(int j = 0; j <= limit; j++){
					if(money>j) dp[i][j] = dp[i-1][j]|dp[i][j];
					else dp[i][j] = dp[i][money]&dp[i-1][j-money]?true:dp[i][j]?true:false;
				}
				money += tmp;
			}
		}

		int maxc = 0;
		for(int i = 1; i <= n; i++){
			for(int j = limit; j >= 2; j--){
				if(dp[i][j]&&prime[j]&&maxc<j){
					maxc = j;
					break;
				}
			}
		}
		if(maxc == 0) cout << "NA" << endl;
		else cout << maxc << endl;
	}
	return 0;
}