#include <iostream>
#include <cstdio>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
#define xMAX 1000001
#define nMAX 31
#define MAX 500001
int v[nMAX];
int dp[nMAX][xMAX];
bool prime[MAX];
int Do,Not;

void sieve(){
  for(int i=0;i<MAX;i++)
    prime[i] = true;

  for(int i = 3; i < xMAX; i += 2)
    for(int j = 3; j * j < i; j += 2)
      if(i % j == 0)
	prime[i/2-1]=false;
}

bool isPrime(int n){
  if(n==0||n==1)
    return false;
  if(n==2)
    return true;
  if(n%2==0)
    return false;
  return prime[n/2-1];
}

void makedp(){
  rep(i,nMAX)
    dp[i][0]=0;
  rep(i,xMAX)
    dp[0][i]=0;
}

void printdp(int n, int x){
  putchar('\n');
  rep(i,n+1){
    printf("%d :",i+1);
    rep(j,x+1){
      printf("%2d ",dp[i][j]);
    }
    putchar('\n'); 
  }
}

void solve(int n, int x){
  int max=0;
  int i,j;

  for(i=1;i<n+1;i++)
    for(j=1;j<x+1;j++){
      Do = dp[i][j-v[i]]+v[i];
      if(Do>x)
	break;
      Not = dp[i-1][j];
      if(j<v[i-1])
	dp[i][j] = Not;
      else{
	if (Do > Not){
	  dp[i][j] = Do;
	  if(max<Do && Do<=x && isPrime(Do))
	    max=Do;
	}
	else
	  dp[i][j] = Not;
      }
    }

  //printdp(n,x);

  if(max)
    cout << max << endl;
  else
    cout << "NA" << endl;
}

int main(){
  sieve();
  makedp();
  v[0]=0;
  for(;;){
    int n,x;
    cin >> n >> x;
    if(!(n+x)) break;
    for(int i=1;i<n+1;i++)
      cin >> v[i];
    solve(n,x);
  }
  return 0;
}