1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <algorithm>
using namespace std;
int primes[25], k;
long long N, res;

void bfs(long long cur, int ip)
{    
  while (ip < k)
  {  
    if (N / primes[ip] < cur || N - N % cur <= res)
    {
      if (cur > res)
        res = cur;
      return;
    }
    else
      bfs(cur * primes[ip], ip);
    ip++;
  }
}

int main()
{
  cin>>k>>N;
  for (int i = 0; i < k; i++)
  {
    cin>>primes[i];
  }
  sort(primes, primes + k);
  bfs(1, 0);
  cout<<res<<endl;
}