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
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <random>
#include <cstdlib>
#include <ctime>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>

using namespace std;

long long closest;

long long tradfind(vector<int> & primes, long long k){
  if(k < 2){
    return k;
  }
  if(primes[0] > 2){
    if(k % 2 == 0){
      k--;
    }
  }
  while(true){
    long long cp = k;
    for(auto a : primes){
       while(cp % (a) == 0){
        cp /= a;
       }
    }  
    if(cp == 1){
      return k;
    } 
    if(primes[0] > 2){
      k--;
    }
    k--;
  }
}



long long findsquarenumb(vector<int> & primes, long long k){
  long long l = 1;
  long long r = k;
  while(l != r - 1){
    long long mid = (l + r) / 2;
    if(mid < k / mid ){
      l = mid;
    } else {
      r = mid;
    }
  }

  long long p = r;
  long long a = tradfind(primes, p);
  long long b = tradfind(primes, k / p);
  return a * b;
}

void brutefind(vector<int> primes, long long k, long long mult, int j = 0, bool changed = true){

  if(k % mult >= (k - closest)){
    return;
  }
  if(changed) closest = max(closest, mult * findsquarenumb(primes, k / mult));
  if(j >= primes.size()){
    return;
  }

  long long cur = primes[j];
  brutefind(primes, k, mult * cur, j + 1, true);
  brutefind(primes, k, mult, j + 1, false);

}

long long searchprime(vector<int> & primes, long long k){

  for(auto a : primes){
    long long cur = 1;
    while(cur <= k / a){
      cur *= a;
    }
    closest = max(cur, closest);
  }

  if(primes.size() == 1){
    return closest;
  }
  if(primes.size() >= 2){
    vector<long long> powersa;
    vector<long long> powersb;
    powersa.push_back(1);
    powersb.push_back(1);
    while(powersa.back() <= k / primes[0]){
      powersa.push_back(powersa.back() * primes[0]);
    }
    while(powersb.back() <= k / primes[1]){
      powersb.push_back(powersb.back() * primes[1]);
    }
    for(auto a : powersa){
      for(auto b : powersb){
        if(a <= k / b){
          closest = max(a * b , closest);
        }
      }
    }
    if(primes.size() == 2){
      return closest;
    }
  }
  if(primes.size() == 3){
    vector<long long> powersa;
    vector<long long> powersb;
    vector<long long> powersc;
    powersa.push_back(1);
    powersb.push_back(1);
    powersc.push_back(1);
    while(powersa.back() <= k / primes[0]){
      powersa.push_back(powersa.back() * primes[0]);
    }
    while(powersb.back() <= k / primes[1]){
      powersb.push_back(powersb.back() * primes[1]);
    }
    while(powersc.back() <= k / primes[1]){
      powersc.push_back(powersc.back() * primes[2]);
    }
    for(auto a : powersa){
      for(auto b : powersb){
        for(auto c : powersc){
          if(a > k / b){
            break;
          }
          if(c <= k / b / a){
            closest = max(a * b * c, closest);
          }
        }
      }
    }
    return closest;
  }
  if(k <= 450000000){
    closest = max(closest, tradfind(primes, k));
  }

  if(k > 450000000){
    brutefind(primes, k, 1);
  }
  

  return closest;

}

int main(){

  int n;
  cin >> n;

  long long k;

  cin >> k;
  vector<int> primes;

  primes.reserve(n);
  for(int i = 0; i < n; i ++){
    int tmp;
    cin >> tmp;
    primes.push_back(tmp);
  }
  sort(primes.begin(), primes.end());
  cout << searchprime(primes, k) << endl;
}