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
58
59
60
61
62
63
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

typedef long long i64;

const int N = 137000 + 10, M = 100 + 10;

int n, pool[M], tot;

int res[N], cnt;

i64 m, ans;
int threshold;

void dfs(int i, int cur) {
  if (i == tot) {
    res[cnt++] = cur;
    return;
  }
  dfs(i + 1, cur);
  while ((i64)cur * pool[i] <= threshold) dfs(i + 1, cur *= pool[i]);
}

void init() {
  scanf("%d%lld", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &pool[i]);
  std::sort(pool, pool + n);
  n = std::unique(pool, pool + n) - pool;
  tot = std::upper_bound(pool, pool + n, 25) - pool;
  threshold = sqrt(m) + 3;
}

void calc(int i, i64 cur) {
  if (cur > m) return;
  if (i == n) {
    int temp = *(std::upper_bound(res, res + cnt, m / cur) - 1);
    ans = std::max(ans, cur * temp);
    return;
  }
  calc(i + 1, cur);
  while (cur <= m / pool[i] + 1) calc(i + 1, cur *= pool[i]);
}

void solve() {
  cnt = 0;
  dfs(0, 1);
  std::sort(res, res + cnt);
  cnt = std::unique(res, res + cnt) - res;
  calc(tot, 1);
}

int main() {
  init();
  solve();
  std::rotate(pool, pool + tot, pool + n);
  tot = n - tot;
  solve();
  printf("%lld\n", ans);
  return 0;
}