Time limit
2s
Memory limit
128 MB
You are given K distinct prime numbers. Consider every positive integer that can be made by choosing one or more of these primes and multiplying the chosen values. A prime may be chosen more than once, and choosing just one prime is also allowed.
With primes 2, 5, and 7, the sequence in increasing order begins 2, 4, 5, 7, 8, 10, 14, 16, 20, 25, 28, 32, 35, ....
Given the K primes, find the N-th number in this increasing sequence. The answer is guaranteed to be a positive integer less than 2^31.
The first line contains K and N (1 <= K <= 100, 1 <= N <= 100000).
The second line contains K distinct prime numbers in increasing order. Each given prime is a positive integer no greater than 541.
Print the N-th number in the sequence described above.