Magic Multiplying Machine

No attempts yetTime limit2sMemory limit64 MB

Problem

The Las Vegas casino Big Jo has a new game machine, the Magic Multiplying Machine (MMM). The machine has NN levers and one large red button. Every lever carries an integer between 11 and MM, and lever ii carries the number aia_i.

A player who wants to play drops a coin into the slot. She then picks some of the levers and pulls them, and finally presses the big red button. The machine blinks its lights, rings its bells, plays a tune, and then announces the score.

The score is decided like this. Let S{1,2,,N}S \subseteq \{1, 2, \dots, N\} be the set of levers the player pulled. The score is the product of the numbers written on those levers, taken modulo MM. Pulling no lever at all is allowed, and then the score is 11.

score=(iSai)modM\text{score} = \left( \prod_{i \in S} a_i \right) \bmod M

Different choices of levers give different scores. Given the description of one machine, find the highest score a player can reach.

Input

The first line contains two integers NN and MM (1N100001 \le N \le 10000, 2M10002 \le M \le 1000).

The second line contains NN integers a1,a2,,aNa_1, a_2, \dots, a_N. Each of them is between 11 and MM.

Output

Print one integer on the first line, the highest score that can be obtained on this machine.