#include<iostream>

using namespace std;

bool pri[1000001];
int price[31];
int n,x;
int dp[31][1000001];
int dps(int i,int sum_m){
  int ss=0;
  int ans;
  if(dp[i][sum_m]!=-1)
    {
      return dp[i][sum_m];
    }
  if(i>=n)
    return 0;
  if(sum_m>=x)
    return 0;
  //  cout<<sum_m<<endl;
  if(pri[price[i]+sum_m] && ans<price[i]+sum_m &&sum_m+price[i]<=x)
    {
      ans=price[i]+sum_m;
      if(ss<ans)
	ss=ans;
    }
  ans= dps(i,price[i]+sum_m);
  if(ss<ans)
    ss=ans;
  ans = dps(i+1,sum_m);
  if(ss<ans)
    ss=ans;
  dps(i+1,sum_m+price[i]);
  if(ss<ans)
    ss=ans;
  
  dp[i][sum_m]=ss;
  //  cout<<ss<<endl;
  return ss;
}

int main()
{
  int ans;
  fill(pri,pri+1000001,true);
  for(int i=2;i<1000001/2;i++)
    {
      for(int x=i+i;x<1000001;x+=i)
	pri[x]=false;
    }
  for(;cin>>n>>x,n;)
    {
      for(int i=0;i<n;i++)
	{
	  cin>>price[i];
	}
      for(int i=0;i<31;i++)
	for(int j=0;j<1000001;j++)
      	  dp[i][j]=-1; 
      ans=dps(0,0);
      if(ans==0)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;
    }
}