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
44
45
#include <iostream>
using namespace std;

int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
int input_prime[25];

//99 sie dzieli przez 11 wiec odrazu udrzucamy
bool checker(unsigned long long int temp, int k) {
    bool flag = false;
    for(int j = 0; j < k; j++) {
        if(temp%input_prime[j] == 0) {
            while(temp%input_prime[j] == 0) {
                temp = temp/input_prime[j];
            }
            if(temp == 1) {
                flag = true;
                break;
            }
        }
    }
    return flag;
}




int main() {
   
    int k;
    
    unsigned long long N, result;
    cin >> k >> N;
    for(int i = 0; i < k; i++) {
        cin >> input_prime[i];
    }

    for(unsigned long long int i = N; i > 0; i--) {
        if(checker(i,k)){
            result = i;
            break;
        }    
    }

    cout << result << endl;
}