#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int n, x;
	vector<int> furui(1000000+1, 0);
	furui[0] = furui[1] = 1;
	for (int i = 2; i*i <= 1000000; i++) {
		if (furui[i] == 0) {
			for (int j = 2; i*j <= x; j++) {
				furui[i*j] = 1;
			}
		}
	}
	while (cin >> n >> x) {
		if (n == 0 && x == 0) {
			break;
		}
		vector<int> en(n);
		vector< vector<int> > dp(n+1, vector<int>(x+1, 0));
		for (int i = 0; i < n; i++) {
			cin >> en[i];
			dp[i+1][en[i]] = 1;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= x; j++) {
				if (j < en[i]) {
					dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
				} else {
					dp[i+1][j] = max(max(dp[i][j], dp[i+1][j-en[i]]), dp[i+1][j]);
				}
			}
		}
		bool hantei = true;
		for (int i = x; i >= 0; i--) {
			if (dp[n][i] > 0 && furui[i] == 0) {
				cout << i << endl;
				hantei = false;
				break;
			}
		}
		if (hantei) {
			cout << "NA" << endl;
		}
	}
	return 0;
}