#include <iostream>
#include <vector>
#include <string>
#include <climits>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n, x;

	vector< int > p(1000001, 1);
	p[1] = 0;
	for(int i = 1; i * i <= 1000000; i++) {
		if(p[i] == 1) {
			for(int j = 2; i * j <= 1000000; j++) {
				p[i * j] = 0;
			}
		}
	}

	while( true ) {
		cin >> n >> x;

		if(n == 0 && x == 0) {
			break;
		}

		vector< int > num(n);

		for(int i = 0; i < n; i++) {
			cin >> num[i];
		}

		vector< vector< int > > ans(n + 1, vector< int >(x + 1, 0));

		for(int i = 0; i < n - 1; i++) {
			for(int j = 0; j <= x; j++) {
				if(j < num[i]) {
					ans[i + 1][j] = ans[i][j];
				} else {
					ans[i + 1][j] = max(ans[i][j], ans[i + 1][j - num[i]] + num[i]);
				}
			}
		}

		int money = 0;
		for(int j = 0; j <= x; j++) {
			if(p[ans[n - 1][j]] == 1) {
				money = max(money, ans[n - 1][j]);
			}
		}
		if(money != 0) {
			cout << money << endl;
		} else {
			cout << "NA" << endl;
		}
	}
}