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
34
35
36
37
38
39
40
41
42
43
#include <algorithm>
#include <cstdio>

using namespace std;

long long p[107];

bool check(const unsigned long long &n, const int &k){
    
    int wsk = k;
    unsigned long long liczba = n;
    
    while(liczba > 1){
        
        if(liczba % p[wsk] != 0) wsk --;
        else liczba /= p[wsk];
        
        if(wsk <= 0) return false;
    }
    
    return true;
}

int main() {
    
    int k;
    unsigned long long N;
    
    scanf("%d%llu", &k, &N);
    for(int i = 1; i <= k; i++) scanf("%lld", &p[i]);
    sort(p+1, p+k+1);
    
    for(unsigned long long i = N; i > p[k]; i--){
        if(check(i, k)){
            printf("%llu\n", i);
            return 0;
        }
    }
    
    printf("%lld\n", p[k]);
    
    return 0;
}