Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese  and Russian. 

For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). 
"k!" means factorial: k! = 1 * 2 * .. * k 

Chef wants to calculate F(p_{1}) + F(p_{2}) + ... + F(p_{n}). 
As answer could be large, help him, calculate value modulo m. 

------ Input ------ 

First line contains two integers n and m.
Next line contains n space separated integers p_{i}.

------ Output ------ 

Output a single line containing one integer --- calculated value modulo m.

------ Constraints ------ 

$1 ≤ n_{} ≤  10^{5}$
$1 ≤ p_{i} ≤  10^{18}$
$1 ≤ m ≤  10^{7}$

------  Subtasks  ------ 

$Subtask #1: 1 ≤ p_{i} ≤  6  (10 points)$
$Subtask #2: 1 ≤ p_{i} ≤  7 * 10^{3} (25 points)$
$Subtask #3: m_{}^{} - prime number (25 points)$
$Subtask #4: _{}^{}original constraints (40 points)$

----- Sample Input 1 ------ 
5 7
1 2 3 4 5
----- Sample Output 1 ------ 
6
----- explanation 1 ------ 
F(1) = 1 * (1! + 1) = 2
F(2) = 1 * (1! + 2) + 2 * (2! + 2) = 3 + 8 = 11
F(3) = 1 * (1! + 3) + 2 * (2! + 3) + 3 * (3! + 3) = 4 + 10 + 27 = 41
F(4) = 1 * (1! + 4) + 2 * (2! + 4) + 3 * (3! + 4) + 4 * (4! + 4) = 5 + 12 + 30 + 112 = 159
F(5) = 1 * (1! + 5) + 2 * (2! + 5) + 3 * (3! + 5) + 4 * (4! + 5) + 5 * (5! + 5) = 794
F(1) + F(2) + F(3) + F(4) + F(5) = 2 + 11 + 41 + 159 + 794 = 1007 

1007 modulo 7 = 6