#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int MAX = 1000000;

int main() {
  static bool is_prime[MAX + 1];
  fill(is_prime, is_prime + MAX + 1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i * i <= MAX; ++i)
    for(int j = i * i; j <= MAX; j += i)
      is_prime[j] = false;
  for(int N, S; cin >> N >> S, N || S; ) {
    static bool can_make[MAX + 1];
    fill(can_make, can_make + MAX + 1, false);
    can_make[0] = true;
    for(int i = 0; i < N; ++i) {
      int x; cin >> x;
      for(int j = 0; j <= S - x; ++j) {
        if(can_make[j]) can_make[j + x] = true;
      }
    }
    int ans = -1;
    for(int i = (int)S; i >= 0; --i) {
      if(can_make[i] && is_prime[i]) {
        ans = i;
        break;
      }
    }
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }
}