#include<bits/stdc++.h>
using namespace std;
#define ANSWER(x) cout<<x<<endl
#define debug(x) cout<<#x<<": "<<x
const int MAX_INT = 1000000;
bool er[1000001];
int n,x,ans;
int v[31];
int solve(int k,int m);
int memo[1000001];
int main(){
  memset(er,true,sizeof(er));
  for(int i=2;i<=sqrt(MAX_INT);i++){
    if(er[i]){
      for(int j=0;i*(j+2)<MAX_INT;j++){
	er[i*(j+2)]=false;
      }
    }
  }
  while(cin >> n >> x, n|x){
    if(!n && !x)break;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<n;i++){
      cin >> v[i];
    }
    
    ans = solve(0,0);
    if(!ans)cout << "NA\n";
    else cout << ans << endl;
  }
}
int solve(int k,int m){
  if(memo[m] != -1)return memo[m];
  if(m > x)return 0;
  else if(k == n){
    if(m == 0)return 0;
    if(er[m])return m;
    else return 0;
  }
  return memo[m] = max(solve(k,m+v[k]),solve(k+1,m));
}