#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vector<int> sieve(int n) {
  vector<int> p(n);
  for(int i=2; i<n; i++) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  return p;
}

int main() {
  vector<int> prime=sieve(1000001);
  int n,m;
  while(cin >> n >> m && (n||m)) {
    bool dp[m+1];
    memset(dp,false,sizeof(dp));
    dp[0]=true;
    int ans=-1;
    rep(i,n) {
      int x;
      cin >> x;
      rep(j,m) {
	if(dp[j] && j+x<=m) {
	  dp[j+x]=true;
	  if(prime[j+x]) ans=max(ans,j+x);
	}
      }
    }
    if(ans==-1) pr("NA");
    else pr(ans);
  }
  return 0;
}
