Pablo is trying to escape from the police master plan which Agent Murphy is trying to execute. While observing some things, he found that the police has a secret code for this plan. Pablo needs to obtain that code!
Pablo got an array of numbers A of length N
There can be many permutations (P1,P2....Pm) of that array.
For each permutation Pi, its code (an integer) is generated by concatenation of all the non-prime numbers in that permutation. Now, there will be many codes, as one code is generated for each permutation. But among those, there exists a secret code.
After some studying on the pattern, Gustavo finds out that the secret code is actually the largest one among all the codes!
Note :- There can be multiple occurrences of the secret code.
Can you help Pablo find the secret code?
INPUT
OUTPUT
CONSTRAINTS
DISTRIBUTION
Let us take the 2nd test case-
There are 3 numbers in the array A - 4, 7, 60
Since N is 3, 6 permutations are possible. Various permutations & their codes are -
P1 - [4,7,60] - 460
P2 - [4,60,7] - 460
P3 - [60,4,7] - 604
P4 - [60,7,4] - 604
P5 - [7,60,4] - 604
P6 - [7,4,60] - 460
Note that only numbers concatenated are non-primes [4,60] and 7 is not present in any of the codes.
Now, Among all these codes, since the secret code is maximum of all, the answer is 604