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
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream>
#include<algorithm>
#include<queue>
#include<list>
#include<stdio.h>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ull long long int
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORD(i,n) for(int i=(n)-1;i>=0;--i)
#define znakow 26
#define dcout 0 && cout
#define INF 9999999
int inline min(int a,int b){return a>b?b:a;}
int inline max(int a,int b){return a<b?b:a;}
int NIL=0;
ull maxi(ull* primes, ull*offsets, ull limit, ull offset, ull multiplier) {

	if (*offsets < offset) return 1;
	if (!*primes) return 1;
	ull prime = *primes;
	//if (limit < prime) return 1;
	ull primeN = 1;
	ull mx = 0;

	while (limit / primeN > 0) {
		ull c = maxi(primes+1, offsets + 1, limit / primeN, (limit % primeN) * multiplier + offset,
			multiplier * primeN) * primeN;
		if (c > mx) mx = c;
		primeN *= prime;
	}
	ull bestOffset = offset + (limit - mx) * multiplier;
	if (bestOffset < *offsets)
		*offsets = bestOffset;
	return mx;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ull *offsets = new ull[110];
	FOR(i,110)offsets[i]=1000000000000000001LL;


	int n;
	ull k;
	cin>>n>>k;
	ull*primes = new ull[n+7];
	FOR(i,n)cin>>primes[i];
	sort(primes,primes+n);
	reverse(primes,primes+n);
	primes[n]=0;
	cout<<maxi(primes, offsets, k, 0, 1)<<endl;

	return 0;
}