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
#include <bits/stdc++.h>
using namespace std;

const int CWIERC = 2944730 / 4 + 1;
const int max_n = 105;
typedef long long ll;
ll N, k, Result, p[max_n];

const ll DU = 1e9;
int licznik = 0, V = 0, U = 0, A, B;
vector<int> v, u;
void gene(int i, ll x)
{
  if (x > DU || licznik > B) return;
  if (i == k) 
  { 
    licznik ++;
    if (A <= licznik && licznik <= B)
    {
      if (V) v.push_back((int) x); 
      if (U) u.push_back((int) x);
    }
    return;
  }
  gene(i+1, x);
  gene(i, x*p[i]);
}

int main()
{
  scanf("%lld%lld", &k, &N);
  for (int i = 0; i < k; i++)
    scanf("%lld", &p[i]);
  p[k] = 1;
  sort(p, p+k);

  for (int i = 0; i < 4; i++)
  {
    licznik = 0;
    V = 1; U = 0; A = CWIERC * i + 1; B = CWIERC * (i+1);
    v.clear(); v.reserve(CWIERC + 2);
    if (i == 0)
    {
      gene(0, 1);
      sort(v.begin(), v.end());
    }
    else
    {
      for (int i = 0; i < (int) u.size(); i++)
        v.push_back(u[i]);
    }

    for (int j = i; j < 5; j++) if (j != i+1)
    {
      if (i == 3 && j == 4) continue;
      bool czy = false;
      if (j == 4){ czy = true; j = i+1; }

      licznik = 0;
      V = 0; U = 1; A = CWIERC * j + 1; B = CWIERC * (j+1);
      if (i != j)
      { 
        u.clear(); u.reserve(CWIERC + 2);
        gene(0, 1);
        sort(u.begin(), u.end());
      }
      else
      {
        u.clear(); u.reserve(CWIERC + 2);
        for (int i = 0; i < (int) v.size(); i++)
          u.push_back(v[i]);
      }

      //continue;

      int pocz = (int) u.size() - 1;
      int pocz2 = (int) v.size() - 1;
      for (int r = 0; r <= k; r++)
      {
        while (pocz2 > 0 && 1LL * v[pocz2] * p[r] >= 1e9) pocz2--;
        int wsk = pocz, pocze = -1;
        if (r == k) 
        {
          wsk = (int) u.size() - 1;
          pocz2 = 0;
        }
        
        for (int x = pocz2; x < (int) v.size(); x++)
        {
          while (wsk >= 0 && 1LL * v[x] * p[r] * u[wsk] > N)
            wsk--;
          
          if (pocze == -1) pocze = pocz = wsk;
          
          if (wsk >= 0) Result = max(Result, 1LL * v[x] * p[r] * u[wsk]);
        }
      }

      if (czy) break;
    }
  }

  printf("%lld\n", Result);
 
  return 0;
}