SP23530 SUFFIX - Suffixes
Description
Find the smallest natural number X such that, if we write X in bases B $ _{1} $ , B $ _{2} $ , ..., B $ _{N} $ , we get strings with suffixes S $ _{1} $ , S $ _{2} $ , ..., S $ _{N} $ , respectively.
The possible digits are 0123456789ABCDEFG...XYZ, with values 0..35. Of course, the number written in base B consists only of the digits with values between 0 and B - 1.
Input Format
In the first line of input there is an integer N (1
In k $ ^{th} $ of the next N lines there is an integer B $ _{k} $ (2
The given bases will be pairwise distinct. Also, the product of the powers B $ _{k} $ ^ lenght(S $ _{k} $ ) will be less than 10 $ ^{18} $ .
Output Format
Print the required X, written in base 10.