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
#include <iostream>

using namespace std;

int main()
{
	short k,a;
	long long n, aktn = 0;
	cin >> k >> n;
	int wart[25] = { 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 };
	bool czy[25] = { false };
	for (int i = 0; i < k; i++)
	{
		cin >> a;
		for (int j = 0; j < 25; j++)
		{
			if (wart[j] == a)
			{
				czy[j] = true;
				break;
			}
		}
	}
	for (int i = 24; i >= 0; i--)
	{
		if (czy[i])
		{
			while (aktn < n)
				aktn += wart[i];
			aktn -= wart[i];
		}
	}
	cout << aktn;
	return 0;
}