#include <iostream>
#include <algorithm>
#define rep(i, a, n) for(int i = a;i < n;i++)
using namespace std;


int n, x;
int m[40];
int dp[40][1000010];


bool judge(int v){
	if(v <= 1) return false;
	if(v == 2) return true;
	for(int i = 2;i*i <= x+1;i++){
		if(v % i == 0) return false;
	}
	return true;
}


void makeDP(){
	rep(i, 1, n+1){
		rep(j, 0, x+1){
			if(j - m[i] >= 0) dp[i][j] = max(dp[i-1][j], dp[i][j - m[i]] + m[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
}


int solve(){
	for(int i = x;i >= 0;i--){
		if(judge(dp[n][i])) return dp[n][i];
	}
	return 0;
}


int main(){
	while(cin >> n >> x, n || x){
		rep(i, 1, n+1) cin >> m[i];

		makeDP();

		int ans = solve();

		if(ans) cout << ans << endl;
		else cout << "NA" << endl;
	}

	return 0;
}