module main;
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;

const int MX = 1000000;

int N, X;
int[MX] dp;
int[30] p;
bool[MX] not_prime, done;
  auto ss = sqrt(cast(real)(MX)) + 1;
  not_prime[0] = not_prime[1] = true;
  for(auto i = 2; i < ss; i++)
  {
    if(not_prime[i])
      continue;
    for(auto j = i + i; j < MX; j += i)
      not_prime[j] = true;;
  }
  while(true)
  {
    readf("%d %d\n", &N, &X);
    if(!N)
      break;
    X++;
    
    for(auto i = 0; i < X; i++)
      dp[i] = 0;

    int ans;
    for(auto i = 0; i < N; i++)
      readf("%d\n", &p[i]);
    for(auto i = 0; i < N; i++)
      for(auto j = p[i]; j < X; j++)
        dp[j] = max(dp[j], dp[j - p[i]] + p[i]);
    
    auto printed = false;
    for(auto i = X - 1; i > 0; i--)
    {
      if(!not_prime[dp[i]])
      {
        writeln(dp[i]);
        printed = true;
        break;
      }
    }
    if(!printed)
      writeln("NA");
  }
}