#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
#define INF (1111111)
int N,X;
int r[31];
bool sosu[1000001];
int dp[1000001];
int solve(int sum){
  if(sum>X) return 0; 
  if(dp[sum]!=-1) return dp[sum];
  int ret=0;
  for(int i=0;i<N;i++){
    ret=max(ret,solve(sum+r[i]));
  }
  if(!sosu[sum]){
    return dp[sum]=max(sum,ret);
  }else{
    return dp[sum]=ret;
  }  
}
main(){
  sosu[0]=true;
  sosu[1]=true;
  for(int i=2;i<1000001;i++){
    if(!sosu[i])
      for(int j=i*2;j<1000001;j+=i){
	if(j>1000000) break;
	sosu[j]=true;
      }
  }
  while(1){
    scanf("%d %d",&N,&X);
    if(N==0 && X==0) break;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
      scanf("%d",&r[i]);
    }
    int res = solve(0);
    if(res==0) puts("NA");
    else printf("%d\n",res);
  }
}