C. Kuroni and Impossible Calculation

链接:https://codeforces.ml/contest/1305/problem/C

To become the king of Codeforces, Kuroni has to solve the following problem.

He is given nn numbers a1,a2,…,ana1,a2,…,an. Help Kuroni to calculate ∏1≤i

If you are not familiar with short notation, ∏1≤i

Input

The first line contains two integers nn, mm (2≤n≤2⋅1052≤n≤2⋅105, 1≤m≤10001≤m≤1000) — number of numbers and modulo.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).

Output

Output the single number — ∏1≤i

Examples

input

Copy

2 10
8 5

output

Copy

3

input

Copy

3 12
1 4 5

output

Copy

0

input

Copy

3 7
1 4 9

output

Copy

1

Note

In the first sample, |8−5|=3≡3mod10|8−5|=3≡3mod10.

In the second sample, |1−4|⋅|1−5|⋅|4−5|=3⋅4⋅1=12≡0mod12|1−4|⋅|1−5|⋅|4−5|=3⋅4⋅1=12≡0mod12.

In the third sample, |1−4|⋅|1−9|⋅|4−9|=3⋅8⋅5=120≡1mod7|1−4|⋅|1−9|⋅|4−9|=3⋅8⋅5=120≡1mod7.

代码:

#include
using namespace std;
long long n,m,t,s1,s2,s;
long long a[200001];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    }
    if(n<=m)
    {
    	s=1;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=i+1;j<=n;j++)
    		{
    			s*=abs(a[i]-a[j])%m;
    			s%=m;
    		}
    	}
    	cout<

 

你可能感兴趣的:(codeforces,数学,ACM)