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
#include <iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include <vector>
#include <stdexcept>
//#include <cassert>
#define ll long long
using namespace std;

const ll SEARCH_TO = 400000000LL;
const int ARRAY_SIZE = 1872209;
ll n;
int k;
int P[100];
ll searchCalls =0;
int vals[ARRAY_SIZE];
int valsSize =0;

void genit(ll left,ll sofar, int pos){
    if(pos==k) {
        vals[valsSize++]= sofar;
   //     assert(valsSize<=ARRAY_SIZE);
        return;
    }
    ll mul = 1;
    while(left/mul >= 1) {
        genit(left/mul, sofar*mul, pos+1);
        mul *= P[pos];
    }
}

ll  doit(ll left, ll pos){
    if(pos==k)return 1;
    if(left < SEARCH_TO) {
        searchCalls++;
        int a =0;int b = valsSize;
        while(a!=b) {
            int c = (a+b)/2;
            if(vals[c]>left){
                b = c;
            }else {
                a=c+1;
            }
        }
        if(a==0)return 1;
        return vals[a-1];
    }
    ll mul = 1;
    ll res = 1;
    while(left/mul >= 1) {
        ll r = mul * doit(left/mul, pos+1);
        res = max(res, r);
        mul *= P[pos];
    }
    return res;
}

ll brut() {
    genit(SEARCH_TO, 1, 0);
    cerr << "generated "<<valsSize<<" values\n";
    sort(vals, vals+valsSize);

    return doit(n,0);
}

ll good() {
    ll limit = min(SEARCH_TO, n);
    limit = min(limit, (ll)(2*sqrt(n)));
    genit(limit, 1, 0);
    cerr << "generated "<<valsSize<<" values\n";
    sort(vals, vals+valsSize);
    cerr << "largest val "<<vals[valsSize-1]<<"\n";
    ll res =1;

    for(int i=0;i<50&&i<valsSize;i++){
        int p1 = 0;
        int p2 = valsSize-1;
        while(p1<valsSize){
            ll mul = 1LL * vals[i]*vals[p1];
            while(n/mul<vals[p2])p2--;
            ll x = mul*vals[p2];
            res = max(res, x);
            p1++;
        }
    }

    return res;
}

int main() {
    std::ios::sync_with_stdio(false);
    istream& my_in = cin;
    //ifstream my_in; my_in.open ("max.in");

    my_in >> k >> n;
    for(int i=0;i<k;i++)my_in >> P[i];
    ll res = good();
    cout <<res<<endl;
    return 0;
}