#include <iostream>

using namespace std;

int main() {

    bool P[1000001];
    fill(P, P + 1000001, true);
    P[0] = P[1] = false;

    for (int i = 0; i <= 1000; i++) {
        if (P[i]) {
            for (int j = i * 2; j <= 1000000; j += i) P[j] = false;
        }
    }

    int n, x;
    while (cin >> n >> x) {
        if ((n | x) == 0) break;

        bool dp[x + 1];
        fill(dp, dp + x + 1, false);
        dp[0] = true;

        for (int i = 0; i < n; i++) {
            int v;
            cin >> v;
            for (int j = 0; j <= x - v; j++) {
                if (dp[j] && !dp[j + v])
                    dp[j + v] = true;
            }
        }

        int ans = -1;
        for (int i = x; i >= 0; i--) {
            if (dp[i] && P[i]) {
                ans = i;
                break;
            }
        }

        if (ans != -1) {
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}
