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
#include <bits/stdc++.h>
using namespace std;

vector<long long> T[25];
int k;
long long N;
long long result = 0;
	
void solve(long long act, int i){
	if(i == k - 1){
		while(act <= N){
			if(act > N/T[i][1]) break;
			act *= T[i][1];
		}
		if(result < act) result = act;
	}
	else{
		for(unsigned int j = 0; j < T[i].size(); j++){
			if(T[i][j] * act <= N) solve(act * T[i][j], i+1);
			else break;
		}
	}
}

int main(){
	long long helpi;
	cin>>k>>helpi;
	N = helpi;
	for(int i = 0; i < k; i++){
		long long x; cin>>x;
		long long act = 1;
		while(act <= N){
			T[i].push_back(act);
			if(act > N/x) break;
			act *= x;
		}
	}

	solve(1, 0);
	cout<<result<<endl;
}