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
#include <algorithm>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;

int main() {
	long long k, n;
	scanf("%lld", &k);
	scanf("%lld", &n);
	bool t[6000001];
	int p[101];
	for (int i = 0; i < 6000001; ++i) {
		t[i] = false;
	}
	for (int i = 0; i < k; ++i) {
		scanf("%d", &p[i]);
	}
	t[1] = true;
	for (int i = 1; i < 6000001; ++i) {
		for (int j = 0; j < k && i * p[j] < 6000001; ++j) {
			if (t[i]) t[i * p[j]] = true;
		}
	}
	while (n > 0) {
		if (t[n]) {
			printf("%d\n", n);
			break;
		}
		n--;
	}
	
	return 0;
}