doju

Count increasing sequences of distinct integers within bounds for which both wrong formulas a_n/g and a_n-n give the wrong parity, modulo q.

Hard8MathNumber theoryCombinatoricsDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

doju enjoys adding new data to problems on an online judge. Watching someone fail because of the data doju added makes doju very happy.

The problem doju is preparing data for today has this input format.

The first line contains an integer nn (1nmaxn1 \le n \le \mathit{maxn}). The second line contains nn distinct integers a1,a2,,ana_1, a_2, \dots, a_n (1aimaxa1 \le a_i \le \mathit{maxa}) in increasing order.

The correct solution first computes the greatest common divisor gg of a1,a2,,ana_1, a_2, \dots, a_n, then computes x=an/gnx = a_n / g - n. It prints odd when xx is odd and even when xx is even.

Two wrong ways of computing xx still get this problem right once in a while.

  1. x=an/gx = a_n / g
  2. x=annx = a_n - n

Both methods print the parity of the xx they computed. Count the data files that make both methods print an answer different from the correct one. Two data files are different when nn differs or the sequence differs.

Given maxn\mathit{maxn}, maxa\mathit{maxa} and qq, write a program that computes the number of data files that make both wrong methods fail, modulo qq.

Input

The first line contains maxn\mathit{maxn}, maxa\mathit{maxa} and qq, separated by spaces. (1maxn300001 \le \mathit{maxn} \le 30000, maxnmaxa109\mathit{maxn} \le \mathit{maxa} \le 10^9, 104q105+12910^4 \le q \le 10^5 + 129)

Output

Print the number of data files that make both wrong methods fail, modulo qq.

Hint

For maxn=3\mathit{maxn} = 3 and maxa=6\mathit{maxa} = 6 there are four such data files: n=1n = 1 with the sequence 22, n=1n = 1 with the sequence 44, n=1n = 1 with the sequence 66, and n=3n = 3 with the sequence 2,4,62, 4, 6.