H. Houraisan Kaguya
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

Houraisan Kaguya is fighting against Fujiwara no Mokou over the moon. Suddenly, Mokou launches a spell "Imperishable Shooting"(just a programming problem, believe it or not) to attack Kaguya, which is as follows.

Given a prime number $$$p$$$ and $$$n$$$ positive integers $$$a_1, a_2, \cdots, a_n$$$ which are strictly less than $$$p$$$.

For two integers $$$a,b~(0\le a,b < p)$$$, we say $$$a$$$ is representable by $$$b$$$ if and only if there exists a positive integer $$$x$$$ that $$$b^x \equiv a ($$$mod $$$p)$$$. Furthermore, we define $$$f(a,b)$$$ as the minimum positive integer $$$u$$$ that $$$a^u$$$ modulo $$$p$$$ is representable by $$$b$$$. If no such $$$u$$$ exists, $$$f(a,b)$$$ is specially defined as 0.

The problem is to determine the value of following formula. $$$$$$\left(\sum_{i=1}^{n}\sum_{j=1}^{n}f(a_i,a_j)\times f(a_j,a_i)\right) \!\!\mod p$$$$$$

Please help Kaguya solve it so that Kaguya can give Mokou the sixth puzzle in the next round.

Input

The first line contains two positive integers $$$n,p~(1\le n \le 100\,000, 2\le p\le 10^{18})$$$, denoting the number of given integers and the given prime number.

The next line contains $$$n$$$ positive integers $$$a_i~(1 \le a_i < p)$$$, denoting the given integers.

Output

Output a single line containing a non-negative integer, denoting the answer.

Example
Input
4 5
1 2 3 4
Output
4