#include <iostream>
#include <algorithm>
#include <cstring>

constexpr int MAX_N = 30, MAX_C = 1000001;
int n, max;
int cost[MAX_N];
int dp[MAX_C];
bool prime_num[MAX_C];

int main() {
	while (1) {
		std::cin >> n >> max;
		if (n + max == 0)
			break;
		std::memset(prime_num, false, sizeof(prime_num));
		std::memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; ++i)
			std::cin >> cost[i];
		for (int i = 2; i * i <= max; ++i) {
			if (!prime_num[i]) {
				for (int j = 2; i*j <= max; ++j)
					prime_num[i*(j + 2)] = true;
			}
		}
		int ans = 0;
		for (int i = 1; i <= max; ++i) {
			dp[i] = dp[i - 1];
			for (int j = 0; j < n; ++j) {
				if (i >= cost[j]) {
					if (!prime_num[dp[i - cost[j]] + cost[j]])
						ans = dp[i - cost[j]] + cost[j];
					dp[i] = std::max(dp[i], dp[i - cost[j]] + cost[j]);
				}
			}
		}
		if (!ans)
			std::cout << "NA" << std::endl;
		else
			std::cout << ans << std::endl;
	}
	return 0;
}