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

He is given $n$ numbers $a_1, a_2, \dots, a_n$. Help Kuroni to calculate $\prod_{1\le i<j\le n} |a_i - a_j|$. As result can be very big, output it modulo $m$.

If you are not familiar with short notation, $\prod_{1\le i<j\le n} |a_i - a_j|$ is equal to $|a_1 - a_2|\cdot|a_1 - a_3|\cdot$ $\dots$ $\cdot|a_1 - a_n|\cdot|a_2 - a_3|\cdot|a_2 - a_4|\cdot$ $\dots$ $\cdot|a_2 - a_n| \cdot$ $\dots$ $\cdot |a_{n-1} - a_n|$. In other words, this is the product of $|a_i - a_j|$ for all $1\le i < j \le n$.


-----Input-----

The first line contains two integers $n$, $m$ ($2\le n \le 2\cdot 10^5$, $1\le m \le 1000$) — number of numbers and modulo.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i \le 10^9$).


-----Output-----

Output the single number — $\prod_{1\le i<j\le n} |a_i - a_j| \bmod m$.


-----Examples-----
Input
2 10
8 5

Output
3
Input
3 12
1 4 5

Output
0
Input
3 7
1 4 9

Output
1


-----Note-----

In the first sample, $|8 - 5| = 3 \equiv 3 \bmod 10$.

In the second sample, $|1 - 4|\cdot|1 - 5|\cdot|4 - 5| = 3\cdot 4 \cdot 1 = 12 \equiv 0 \bmod 12$.

In the third sample, $|1 - 4|\cdot|1 - 9|\cdot|4 - 9| = 3 \cdot 8 \cdot 5 = 120 \equiv 1 \bmod 7$.

Difficulty: MEDIUM_HARD
Tags: Number theory

Combinatorics

Mathematics

Complete search
Skill types: Complete search

Starter code:

Solutions:
def main():
	(n, m) = [int(i) for i in input().split()]
	if n > m:
		print(0)
		return
	a = [int(i) for i in input().split()]
	s = 1
	for i in range(0, len(a), 1):
		for j in range(i + 1, len(a), 1):
			s = s * abs(a[i] - a[j]) % m
	print(s)
main()


import sys
import copy
input = sys.stdin.readline
from math import *
(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
d = {}
s = 1
p = []
for i in a:
	if i % m in d:
		print(0)
		exit(0)
	else:
		d[i % m] = 1
		p.append(i % m)
for i in range(len(p)):
	for j in range(i + 1, len(p)):
		s *= abs(a[i] - a[j])
		s %= m
print(s % m)


R = lambda : map(int, input().split())
(n, m) = R()
a = (*R(),)
r = n <= m
for i in range(r * n):
	for j in range(i):
		r = r * abs(a[j] - a[i]) % m
print(r + 0)


(n, m) = map(int, input().split())
x = [int(w) for w in input().split()]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(x[i] - x[j])
			ans %= m
	print(ans)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if n > m:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans = ans % m
print(ans)


import math as mt
import sys, string
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappush, heapify, heappop
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
l = L()
if n <= m:
	a = 1
	for i in range(n):
		for j in range(i + 1, n):
			a *= abs(l[i] - l[j])
			if a == 0:
				break
			a %= m
	print(a)
else:
	print(0)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
vals = list(map(int, input().split()))
if n <= m:
	prod = 1
	for s in range(n):
		for j in range(s + 1, n):
			prod *= abs(vals[s] - vals[j])
			prod = prod % m
	print(prod)
else:
	print(0)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
res = 1
if n > m:
	print(0)
else:
	for i in range(n):
		for j in range(i + 1, n):
			res *= abs(arr[i] - arr[j])
			res = res % m
	print(res)


from math import *
(n, m) = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(0, n):
		for j in range(i + 1, n):
			ans = ans % m * (abs(arr[i] - arr[j]) % m) % m
	print(ans)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	(n, m) = [int(x) for x in stdin.readline().split()]
	a = [int(x) for x in stdin.readline().split()]
	if n <= m * 2:
		outp = 1
		for i in range(n):
			for j in range(i + 1, n):
				outp = outp * abs(a[i] - a[j]) % m
		stdout.write('%d' % outp)
	else:
		stdout.write('0')
	return 0
main()


import sys
import collections
import itertools
input = sys.stdin.readline

def main():
	(N, M) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	c = collections.Counter()
	for a in A:
		c[a % M] += 1
		if c[a % M] == 2:
			print(0)
			return
	ans = 1
	for (i, j) in itertools.combinations(A, 2):
		ans = ans * abs(i - j) % M
	print(ans % M)
main()


(n, m) = map(int, input().split())
arr = [int(k) for k in input().split()]
fat = 1
if n > m:
	print(0)
else:
	for i in range(n - 1):
		for j in range(i + 1, n):
			fat = fat * (abs(arr[i] - arr[j]) % m) % m
	print(fat)


(n, m) = sorted(list(map(int, input().strip().split(' '))))
a = sorted(list(map(lambda x: int(x), input().strip().split(' '))))
ans = 1
if m < n:
	print(0)
else:
	for i in range(n):
		for j in range(i):
			ans = ans * abs(a[i] - a[j]) % m
	print(ans)


(n, m) = map(int, input().split())
x = 0
a = list(map(int, input().split()))
s = 1
if n > 1000:
	print('0')
else:
	while x < n:
		y = x + 1
		while y < n:
			s *= abs(a[x] - a[y])
			s %= m
			y += 1
		x += 1
	print(s)


def main():
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = [None] * k
	for i in range(n):
		y = i % k
		if l1[y] is not None:
			print(0)
			return
		l1[y] = y
	l.sort()
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * (l[j] - l[i]) % k
	print(ans)
main()


def solve():
	(n, m) = [int(s) for s in input().split(' ')]
	A = [int(s) for s in input().split(' ')]
	if n > m:
		print('0')
		return
	mA = [a % m for a in A]
	if len(mA) > len(set(mA)):
		print('0')
		return
	ans = 1
	for i in range(len(A)):
		for j in range(i + 1, len(A)):
			ans *= abs(A[i] - A[j]) % m
			ans %= m
	print(ans)
solve()


def check_root(n, d):
	return n * n + 2 * n + 1 >= 4 * d

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_product(n, m, arr):
	product = 1
	if n <= m:
		for i in range(n):
			for j in range(i + 1, n):
				product = product * abs(arr[i] - arr[j]) % m
		return product
	return 0
t = 1
while t:
	t = t - 1
	(n, m) = map(int, input().split())
	l = list(map(int, input().strip().split()))[:n]
	print(find_product(n, m, l))


(n, m) = map(int, input().split())
ai = [*map(int, input().split())]
res = 1
if n > m:
	print(0)
	exit(0)
for i in range(n):
	for j in range(i + 1, n):
		res *= abs(ai[i] - ai[j]) % m
		res %= m
print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = 'abcdefghijklmnopqrstuvwxyz'
for _ in range(1):
	(n, m) = f()
	l = il()
	ans = 1
	if n > m:
		print(0)
	else:
		for i in range(n - 1):
			for j in range(i + 1, n):
				ans = ans * abs(l[i] - l[j]) % m
		print(ans)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
pro = 1
check = 0
if n <= m:
	for i in range(n - 1):
		for j in range(i + 1, n):
			if abs(l[i] - l[j]) % m == 0:
				exit(print(0))
				break
			pro *= abs(l[i] - l[j])
			pro %= m
	exit(print(pro))
else:
	print(0)


(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(l[i] - l[j]) % m
	print(ans)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if n > m:
	print(0)
else:
	a = 1
	f = True
	for i in range(0, n - 1):
		if f:
			for j in range(i + 1, n):
				a = a * abs(l[i] - l[j]) % m
				if a == 0:
					f = False
					break
	print(a)


from collections import Counter
from itertools import combinations
from functools import reduce

def solve(n, m, arr):
	if n > m:
		return 0
	check = len([True for cnt in Counter(map(lambda x: x % m, arr)).values() if cnt > 1])
	if check > 0:
		return 0
	res = reduce(lambda cum, p: cum * abs(p[0] - p[1]) % m, combinations(arr, 2), 1)
	return res
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve(n, m, arr))


INT_MAX = 10 ** 18 + 7
MOD = 10 ** 9 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]
(n, m) = INPUT()
A = INPUT()
F = 1
Xmod = [0 for i in range(m)]
multiple = [0 for i in range(m)]
for i in range(n):
	d = A[i] % m
	Xmod[d] += 1
	multiple[d] = A[i] // m
for i in range(m):
	if Xmod[i] > 1:
		print(0)
		break
else:
	for i in range(m):
		if Xmod[i] == 1:
			for j in range(i + 1, m):
				if Xmod[j] == 1:
					F = F * abs(m * multiple[i] + i - m * multiple[j] - j) % m
	print(F % m)


(N, mod) = map(int, input().split())
a = list(map(int, input().split()))
if N > mod:
	print(0)
elif N <= mod:
	ans = 1
	for i in range(N):
		for j in range(i + 1, N):
			ans *= abs(a[j] - a[i])
			ans %= mod
	print(ans)


import math
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if n <= m:
	mul = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			t = l[i] - l[j]
			mul = mul * abs(t)
			mul %= m
	print(mul % m)
else:
	print('0')


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
p = 1
if n > m:
	print(0)
else:
	for i in range(0, n - 1):
		for j in range(i + 1, n):
			p *= abs(a[i] - a[j])
			p = p % m
	print(p)


(n, m) = [int(i) for i in input().split()]
numbers = [int(i) for i in input().split()]
answer = 1
if n > m:
	print(0)
	exit()
if len(numbers) == len(set(numbers)):
	for i in range(n):
		for j in range(i + 1, n):
			answer = answer * abs(numbers[i] - numbers[j]) % m
	print(answer)
else:
	print(0)


import sys
(n, m) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(arr[i] - arr[j])
			ans = ans % m
	print(ans % m)


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
(n, m) = minput()
a = linput()
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)


from collections import deque
import sys
input = sys.stdin.readline
(n, MOD) = list(map(int, input().split()))
a = list(map(int, input().split()))
if n > MOD:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= MOD
print(ans)


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
(n, m) = int_arr()
arr = int_arr()
if n > m:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(arr[i] - arr[j])
		ans = ans % m
print(ans)


from sys import stdin
input = stdin.readline

def getAns(n, m, d):
	b = [0] * m
	for i in d:
		b[i % m] += 1
		if b[i % m] == 2:
			return 0
	prod = 1
	for i in range(n - 1, -1, -1):
		for j in range(i - 1, -1, -1):
			prod *= abs(d[i] - d[j]) % m
			prod %= m
	return prod
(n, m) = map(int, input().split())
d = list(map(int, input().split()))
print(getAns(n, m, d))


import sys, math
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, m) = invr()
ara = inlt()
if n > m:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(ara[i] - ara[j])
		ans %= m
print(ans)


import os, sys
from collections import defaultdict, Counter, deque
from io import BytesIO, IOBase
from math import gcd, inf

def main():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	if m >= n:
		an = 1
		for i in range(n):
			for j in range(i + 1, n):
				an = an * abs(a[i] - a[j]) % m
		print(an)
	else:
		print(0)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	inp = lambda : [int(x) for x in input().split()]
	(n, m) = inp()
	a = inp()
	if n > m:
		print(0)
		return
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
mu = 1
lol = 0
up = 10000000
for i in range(n):
	for j in range(i + 1, n):
		mu = mu * abs(l[i] - l[j])
		mu = mu % m
		if mu == 0:
			lol = 1
			break
		up -= 1
		if up == 0:
			break
	if lol or up == 0:
		break
if up == 0:
	print(0)
else:
	print(mu)


(n, m) = map(int, input().split())
arr = [int(x) for x in input().split()]
if m < n:
	print(0)
else:
	result = 1
	for i in range(n):
		for j in range(i + 1, n):
			r = abs(arr[i] - arr[j])
			result = result * r % m
	print(result)


(n, m) = [int(i) for i in input().strip().split()]
a = [int(i) for i in input().strip().split()]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans = ans * abs(a[i] - a[j]) % m
print(ans)


(number, mod) = map(int, input().split())
li = list(map(int, input().split()))
if number > mod:
	print(0)
else:
	res = 1
	for x in range(number):
		for y in range(x + 1, number):
			res *= abs(li[x] - li[y])
			res %= mod
	print(res)


from copy import deepcopy
(n, m) = list(map(int, input().split()))
nums = list(map(int, input().split()))
nums_sorted = deepcopy(nums)
nums_sorted = list(map(lambda x: x % m, nums_sorted))
nums_sorted.sort()
zero = False
for i in range(1, len(nums_sorted)):
	if nums_sorted[i] == nums_sorted[i - 1]:
		zero = True
		break
if zero:
	print('0')
else:
	prod = 1
	for i in range(len(nums)):
		for j in range(i + 1, len(nums)):
			res = nums[i] - nums[j]
			if res < 0:
				res %= m
				res -= m
				res = abs(res)
			prod *= res
			prod %= m
	print(abs(prod))


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if n > m:
	print(0)
else:
	r = 1
	for i in range(n):
		for s in range(i + 1, n):
			r = r * abs(l[i] - l[s])
			r = r % m
	print(r)


import math
(N, M) = map(int, input().split())
A = list(map(int, input().split()))

def mulmod(a, b, mod):
	res = 0
	a = a % mod
	while b > 0:
		if b % 2 == 1:
			res = (res + a) % mod
		a = a * 2 % mod
		b //= 2
	return res % mod
ans = 0
if N <= M:
	ans += 1
	for i in range(N):
		for j in range(i + 1, N):
			ans = ans * (abs(A[i] - A[j]) % M) % M
print(ans % M)


(n, mod) = map(int, input().split())
arr = list(map(int, input().split()))
if n > mod or n > 1000:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(arr[i] - arr[j]) % mod
			ans = ans % mod
	print(ans % mod)


from operator import mul
from functools import reduce

def main():
	(n, m) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	x = 1
	if n > m:
		print(0)
	else:
		for i in range(n):
			a = l[i + 1:]
			a = list(map(lambda x: abs(x - l[i]), a))
			x = x * reduce(mul, a, 1) % m
		print(x)
main()


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if n > m:
		print(0)
	else:
		p = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				p = p * abs(a[i] - a[j]) % m
				if p == 0:
					break
			if p == 0:
				break
		print(p)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
if n > m:
	print(0)
	exit()
arr.sort()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= arr[j] - arr[i]
		ans %= m
print(ans)


(n, m) = map(int, input().split())
a = sorted(map(int, input().split()))
if n <= m:
	d = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			d = d * abs(a[i] - a[j]) % m
	print(d)
else:
	print(0)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
mods = [0] * m
ans = 1
if n > m:
	print(0)
	exit()
for i in range(n):
	for j in range(i + 1, n):
		ans = ans * abs(x[i] - x[j]) % m
print(ans)


import math, collections, sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
d = collections.defaultdict(int)
for i in range(n):
	d[a[i] % m] += 1
for i in d.items():
	if i[1] > 1:
		print(0)
		exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= m
print(ans)


(n, m) = input().split()
a = input().split()
n = int(n)
m = int(m)
for i in range(n):
	a[i] = int(a[i])
if n > m:
	print(0)
else:
	a.sort()
	result = 1
	for i in range(n):
		for j in range(i + 1, n):
			result = result * (a[j] - a[i]) % m
	print(result)


import sys
(n, m) = map(int, input().split())
lst = list(map(int, input().split()))
if n > m:
	sys.exit(print(0))
sol = 1
for i in range(n):
	for j in range(i + 1, n):
		sol = sol * abs(lst[i] - lst[j])
		sol %= m
print(sol)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
v = set()
for num in a:
	if num % m in v:
		print(0)
		exit(0)
	v.add(num % m)
ans = 1
a.sort()
for i in range(n):
	for j in range(i + 1, n):
		ans *= a[j] - a[i]
		ans %= m
print(ans)


import traceback
import math
from collections import defaultdict
from functools import lru_cache

def main():
	(N, mod) = map(int, input().split())
	nums = list(map(int, input().split()))
	ans = 1
	if N > mod:
		return 0
	for i in range(N):
		for j in range(i + 1, N):
			ans = ans * abs(nums[i] - nums[j]) % mod
			if ans == 0:
				return ans
	return ans
try:
	ans = main()
	print(ans)
except Exception as e:
	traceback.print_exc()


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
lis = list(map(int, input().split()))
if n > len(set(lis)):
	print(0)
	exit()
p = 1
for i in range(1, n):
	for j in range(i):
		p = p * abs(lis[i] - lis[j]) % m
		if p == 0:
			print(0)
			exit()
print(p)


def solve():
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	d = dict()
	l2 = []
	for i in range(m):
		l2.append(i)
	d = d.fromkeys(l2, 0)
	for i in range(n):
		v = l1[i] % m
		d[v] += 1
		if d[v] != 1:
			print(0)
			return
	p = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			p *= abs(l1[i] - l1[j]) % m
			p = p % m
			if p == 0:
				print(0)
				return
	print(p % m)
solve()


def main():
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split(' ')]
	if n > m:
		print(0)
		return
	s = 1
	for i in range(n):
		for j in range(i + 1, n):
			s *= abs(arr[i] - arr[j])
			s %= m
	print(s)
main()


(n, m) = map(int, input().split())
ar = list(map(int, input().split()))
st = set(map(lambda u: u % m, ar))
if len(st) != len(ar):
	print(0)
else:
	res = 1
	for (i, u) in enumerate(ar):
		for v in ar[i + 1:]:
			res = res * abs(u - v) % m
	print(res)


def main():
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	s = 1
	if n > m:
		s = 0
	else:
		for i in range(n):
			for j in range(i + 1, n):
				if s != 0:
					s = s * abs(a[i] - a[j]) % m
				else:
					break
	print(s)
main()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
am = list()
d = set()
for i in range(n):
	am.append(a[i] % m)
	if am[i] in d:
		print(0)
		exit()
	d.add(am[i])
ans = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		if a[i] < a[j]:
			ans = ans * (abs(am[i] - am[j] - m) % m) % m
		else:
			ans = ans * (abs(m + am[i] - am[j]) % m) % m
print(ans)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 1
if n <= m:
	(i, j) = (0, 0)
	while i < n:
		j = i + 1
		while j < n:
			ans *= abs(a[i] - a[j])
			ans %= m
			j += 1
		i += 1
else:
	ans = 0
print(ans)


from collections import defaultdict
(n, m) = list(map(int, input().split()))
l = list(map(int, input().split()))
ll = [x % m for x in l]
d = defaultdict(int)
res = 1
for x in ll:
	d[x] += 1
	if d[x] > 1:
		res = 0
if res == 0:
	print(res)
else:
	for i in range(len(l)):
		for j in range(i + 1, len(l)):
			res *= abs(l[j] - l[i])
			res %= m
	print(res)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
s = 1
if n > m:
	print(0)
else:
	for i in range(0, n):
		for j in range(i + 1, n):
			s = s * abs(x[i] - x[j]) % m
	print(s % m)


def abs(a):
	if a > 0:
		return a
	else:
		return -1 * a
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print('0')
else:
	pr = 1
	for i in range(n):
		for j in range(i + 1, n):
			pr = pr * abs(a[i] - a[j])
			pr = pr % m
	print(pr)


from itertools import combinations
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i] % m for i in range(n)]
if len(set(b)) < n:
	print(0)
	return
ans = 1
for (i, j) in combinations(a, 2):
	ans = ans * abs(i - j) % m
print(ans)


from sys import stdin, stdout
t = 1
for _ in range(t):
	(n, m) = stdin.readline().strip().split(' ')
	(n, m) = (int(n), int(m))
	arr = list(map(int, stdin.readline().strip().split(' ')))
	if n > m:
		stdout.write('0\n')
	else:
		arr = sorted(arr)[::-1]
		for i in range(len(arr)):
			arr[i] = arr[i] % m
		ans = 1
		for i in range(len(arr)):
			for j in range(i + 1, len(arr)):
				ans = ans * (arr[i] - arr[j]) % m
		stdout.write(str(ans) + '\n')


from math import ceil, gcd, sqrt

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
(n, m) = mi()
a = li()
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			x = abs(a[i] - a[j])
			if x != 0:
				x %= m
			ans = ans * x % m
	print(ans)


(n, mod) = map(int, input().split())
a = list(map(int, input().split()))
if mod < n:
	print(0)
	exit()
ret = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		ret *= abs(a[i] - a[j])
		ret %= mod
print(ret)


def main():
	(n, m) = tuple(map(int, input().split()))
	data = sorted(list(map(int, input().split())))
	result = 1
	for i in range(n):
		for j in range(i):
			result *= abs(data[i] - data[j])
			result %= m
			if result == 0:
				break
	print(result)
main()


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
pdt = 1
if n <= m:
	for i in range(n - 1):
		for j in range(i + 1, n):
			pdt = pdt * (abs(a[i] - a[j]) % m)
			pdt = pdt % m
	print(pdt)
else:
	print(0)


import sys
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
(n, m) = get_list()
lst = get_list()
if n > m:
	print(0)
else:
	result = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			result = result * abs(lst[i] - lst[j]) % m
			if result == 0:
				flag = False
				break
	print(result % m)


from collections import defaultdict
import sys
(n, m) = list(map(int, input().strip().split()))
a = list(map(int, input().strip().split()))
a.sort()
modulos = [0] * m
if len(a) > m:
	print(0)
	sys.exit()
res = 1
for i in range(len(a)):
	for j in range(i):
		res = res * abs(a[i] - a[j]) % m
print(res)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
mem = []
if len(a) != len(list(set(a))) or n > m:
	print(0)
else:
	for i in range(len(a)):
		p = 1
		for j in range(i - 1, -1, -1):
			p = p * abs(a[j] - a[i])
		cur = p
		if i > 0:
			cur = cur * mem[i - 1]
		mem.append(cur % m)
	print(mem[-1] % m)


(n, m) = map(int, input().split())
ls = [0 for i in range(1001)]
a = input().split()
for i in range(n):
	a[i] = int(a[i])
	ls[a[i] % m] += 1
flag = True
for i in range(1001):
	if ls[i] > 1:
		flag = False
		break
if flag == False:
	print(0)
else:
	a.sort(reverse=True)
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= a[i] - a[j]
			ans %= m
	print(ans)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

def MI():
	return map(int, input().split())

def S():
	return input()

def MS():
	return map(str, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def print_matrix(d):
	for i in range(len(d)):
		print(d[i])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def main():
	(n, m) = MI()
	a = LI()
	ans = 1
	if n > m:
		exit(print(0))
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)
main()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = LI()
		c = collections.Counter([_ % m for _ in a])
		if any((v > 1 for v in c.values())):
			rr.append(0)
			continue
		r = 1
		for i in range(n):
			ai = a[i]
			for aj in a[i + 1:]:
				r *= abs(ai - aj)
				r %= m
		rr.append(r)
	return JA(rr, '\n')
print(main())


(N, M) = map(int, input().split())
A = sorted([int(a) for a in input().split()])
if N > M:
	print(0)
else:
	s = 1
	for i in range(N):
		for j in range(i):
			s = s * (A[i] - A[j]) % M
	print(s)


(n, m) = map(int, input().split())
li = list(map(int, input().split()))
res = 1
if n > 10000:
	print(0)
	exit()
for i in range(n):
	for j in range(i + 1, n):
		res = res * abs(li[i] - li[j]) % m
print(res)


(n, m) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
if n > m:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans = ans * abs(a[i] - a[j])
		ans = ans % m
print(ans)


(n, m) = map(int, input().split())
A = list(map(int, input().split()))
Ans = 1
if n > 1000:
	print(0)
else:
	for i in range(n - 1):
		for j in range(i + 1, n):
			Ans = Ans * abs(A[i] - A[j]) % m
	print(Ans % m)


(n, m) = map(int, input().split())
ar = [int(x) for x in input().split()]
d = {}
ct = 0
md = {}
for i in range(n):
	if ar[i] != ar[i] % m:
		ct += 1
		md[ar[i] % m] = ar[i] // m
	ar[i] = ar[i] % m
	if ar[i] not in d:
		d[ar[i]] = 1
	else:
		d[ar[i]] += 1
sm = 1
for i in range(0, m):
	if i in d:
		for j in range(i, m):
			if j in d:
				if j == i and d[j] == 1:
					continue
				val = d[i] * d[j]
				if i not in md and j not in md:
					v = abs(i - j) % m
				elif i in md and j in md:
					v = abs(md[i] * m + i - (md[j] * m + j)) % m
				elif i in md:
					v = (i - j) % m
				else:
					v = (j - i) % m
				if i - j:
					ct += 1
				v = val % m * v % m
				sm = sm * v % m
print(sm)


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import sys
import copy

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, m) = get_ints()
a = get_array()
if n > m:
	print(0)
else:
	res = 1
	for i in range(n):
		for j in range(i + 1, n):
			res = res * (abs(a[i] - a[j]) % m) % m
	print(res)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial
from collections import deque
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * (abs(l[i] - l[j]) % m) % m
	print(ans)


(n, m) = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
if n <= m:
	prod = 1
	for i in range(n):
		for j in range(i + 1, n):
			prod *= abs(l[i] - l[j])
			prod %= m
	print(prod)
else:
	print(0)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, m) = mi()
a = li()
if n > m:
	print(0)
else:
	ans = 1
	a.sort()
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * (a[j] - a[i]) % m
	print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (m + 1)
c = [0] * (m + 1)
for i in a:
	b[i % m] += 1
	c[i % m] = 1
if max(b) > 1:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= m
print(ans)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	(n, m) = lin()
	a = lin()
	x1 = [0] * m
	for i in a:
		x1[i % m] += 1
	if max(x1) > 1:
		print(0)
	else:
		ans = 1
		for i in range(n):
			for j in range(i + 1, n):
				ans = ans * abs(a[i] - a[j]) % m
		print(ans % m)
main()


from math import *
t = 1
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if n <= m:
		f = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				k = abs(a[i] - a[j])
				s = k
				f = f * s
				f = f % m
				if f == 0:
					break
			if f == 0:
				break
		print(f)
	else:
		print(0)


import sys
import bisect as bi
input = sys.stdin.readline
inf = int(10000000000.0)
(n, mod) = map(int, input().split())
lis = sorted(map(int, input().split()))
if n > 1000:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans % mod * (abs(lis[i] - lis[j]) % mod) % mod
			if ans == 0:
				break
		if ans == 0:
			break
	print(ans)


from collections import Counter
from itertools import combinations
from functools import reduce

def solve(n, m, arr):
	if n > m:
		return 0
	check = any(map(lambda x: x > 1, Counter(map(lambda x: x % m, arr)).values()))
	if check:
		return 0
	res = reduce(lambda cum, p: cum * abs(p[0] - p[1]) % m, combinations(arr, 2), 1)
	return res
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
print(solve(n, m, arr))


import math
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			temp = abs(arr[i] - arr[j]) % m
			ans = ans * temp % m
	print(ans)


(n, m) = map(int, input().split())
array = list(map(int, input().split()))
if n > m:
	print(0)
else:
	answer = 1
	for index in range(n):
		for index_ in range(index + 1, n):
			answer *= abs(array[index] - array[index_])
			answer %= m
	print(answer)


(n, m) = map(int, input().split())
aa = [int(i) for i in input().split()]
if n > m:
	print(0)
else:
	pro = 1
	for i in range(0, len(aa)):
		for j in range(i + 1, len(aa)):
			pro *= abs(aa[i] - aa[j])
			pro %= m
	print(pro % m)


(n, k) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
if n > k:
	print('0')
else:
	ans = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			ans = ans % k * (abs(arr[i] - arr[j]) % k)
	print(ans % k)


def solve(A, n, mod):
	li = []
	A.sort()
	seen = {}
	for it in A:
		v = it % mod
		if v in seen:
			print(0)
			return
		else:
			seen[v] = True
			li.append(v)
	ans = 1
	ln = len(li)
	for i in range(ln - 1):
		for j in range(i + 1, ln):
			v = (li[j] - li[i]) % mod
			ans = ans * v % mod
	print(ans)
(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
solve(arr, n, m)


from collections import defaultdict

def solve(N, M, A):
	total = 0
	indices = defaultdict(list)
	for (i, x) in enumerate(A):
		indices[i % M].append((i, x))
	if any((len(v) > 1 for v in indices.values())):
		return 0
	total = 1
	for (k1, v1) in indices.items():
		for (k2, v2) in indices.items():
			if k1 < k2:
				assert len(v1) == len(v2) == 1
				(i, x) = v1[0]
				(j, y) = v2[0]
				if i < j:
					total = total * abs(x - y) % M
				else:
					total = total * abs(y - x) % M
	return total
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
ans = solve(N, M, A)
print(ans)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
	quit()
f = set()
NULL = False
for i in range(n):
	if a[i] % m in f:
		print(0)
		quit()
	f.add(a[i] % m)
res = 1
for i in range(n):
	for j in range(i + 1, n):
		res = res * abs(a[i] - a[j]) % m
print(res)


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > 1000:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(a[i] - a[j]) % m
	print(ans)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if len(a) > m:
	print(0)
else:
	prod = 1
	for j in range(1, n):
		for i in range(j):
			prod *= abs(a[i] - a[j]) % m
			prod %= m
	print(prod)


import sys

def input():
	return sys.stdin.readline()

def iinput():
	return int(input())

def rinput():
	return input().split()

def rlinput():
	return [int(i) for i in input().split()]

def main():
	(n, m) = map(int, rinput())
	q = sorted(rlinput())
	res = 1
	if n > m:
		print(0)
		return 0
	for i in range(n):
		for o in range(n - 1 - i):
			res = res * abs(q[i] - q[i + o + 1]) % m
			if res == 0:
				print(0)
				return 0
	print(res)
for i in range(1):
	main()


temp = input().split()
n = int(temp[0])
m = int(temp[1])
a = map(lambda x: int(x), input().split())
if n > m:
	print('0')
else:
	import itertools
	S = itertools.combinations(a, 2)
	ans = 1
	for i in S:
		ans *= abs(i[0] - i[1])
		ans %= m
	print(ans)


import os
import sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd, log
from collections import *
from bisect import *
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
g = lambda : input().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(n, m) = gil()
a = gil()
if m < n:
	print(0)
	exit()
ans = 1
for i in range(n):
	if ans == 0:
		break
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j]) % m
		ans %= m
		if ans == 0:
			break
print(ans)


import functools
(n, p) = map(int, input().split())
lst = list(map(int, input().split()))
res = 1
if n > p:
	print(0)
else:
	lst = [abs(lst[i] - lst[j]) % p for i in range(n) for j in range(i + 1, n)]
	print(functools.reduce(lambda a, b: a * b % p, lst))


liste = input().split()
size_problem = int(liste[0])
modulo = int(liste[1])
liste = input().split()
if size_problem > modulo:
	print(0)
else:
	liste = [eval(i) for i in liste]
	liste.sort(reverse=True)
	prod = 1
	for i in range(0, size_problem - 1):
		for j in range(i + 1, size_problem):
			prod *= liste[i] - liste[j]
			prod = prod % modulo
		if prod == 0:
			break
	print(prod)


INF = 10 ** 10

def main():
	(n, m) = get_list()
	li = get_list()
	if len(set(li)) < len(li) or len(li) > m:
		print(0)
	else:
		res = 1
		for i in range(len(li)):
			for j in range(i + 1, len(li)):
				res = res * abs(li[i] - li[j]) % m
		print(res)
import sys
from collections import defaultdict, Counter, deque
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
main()
print(*out, sep='\n')


(a, b) = map(int, input().split())
c = list(map(int, input().split()))
if a > b + 1:
	print(0)
else:
	d = 1
	for i in range(a):
		for y in range(i + 1, a):
			d = d * abs(c[i] - c[y]) % b
	print(d)


from sys import stdin
n = 0
m = 0
numbers = list()

def solve():
	global n, m
	global numbers
	ans = 0
	if n <= m:
		ans = 1
		for i in range(n):
			for j in range(i + 1, n):
				ans *= abs(numbers[i] - numbers[j])
				ans %= m
	print(ans)

def getInput():
	global n, m
	global numbers
	(n, m) = map(int, stdin.readline().split())
	numbers = list(map(int, stdin.readline().split()))
	pass

def test():
	global n, m
	global numbers
	testSet = [[2, 10, [8, 5]], [3, 12, [1, 4, 5]], [3, 7, [1, 4, 9]]]
	for t in testSet:
		(n, m) = (t[0], t[1])
		numbers = t[2]
		solve()
getInput()
solve()


R = lambda : map(int, input().split())
(n, m) = R()
a = list(R())
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(a[i] - a[j]) % m
	print(ans)


(n, m) = map(int, input().split(' '))
y = list(map(int, input().split()))
arr = [0] * m
flag = 0
for i in range(n):
	arr[y[i] % m] += 1
	if arr[y[i] % m] >= 2:
		flag = 1
		break
if flag == 1:
	print(0)
else:
	i = 0
	s = 1
	while i < n:
		j = i + 1
		while j < n:
			x = abs(y[i] - y[j])
			x = x % m
			s = s * x
			s = s % m
			j += 1
		i += 1
	print(s % m)


from sys import stdin, stdout

def cout(x):
	print(x, end=' ')
	return
(n, m) = map(int, input().split())
v = [int(i) for i in stdin.readline().split()]
if n > m:
	exit(print(0))
a = 1
for i in range(n):
	for j in range(i + 1, n):
		a *= abs(v[i] - v[j]) % m
		a %= m
print(a)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
else:
	temp = 1
	for i in range(n):
		for s in range(i + 1, n):
			temp = temp * abs(a[i] - a[s])
			temp = temp % m
	print(temp)


from sys import stdin

def main():
	readline = stdin.readline
	(n, m) = map(int, readline().split())
	a = list(map(int, readline().split()))
	if n > m:
		print(0)
	else:
		result = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				result *= abs(a[i] - a[j])
				result %= m
		print(result)
main()


from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
(n, m) = arr_in()
a = arr_in()
result = 0
if n <= m:
	result = 1
	for i in range(n):
		for j in range(i + 1, n):
			result *= abs(a[i] - a[j])
			result %= m
out(result)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
	exit()
pie = 1
for i in range(n):
	for j in range(i + 1, n):
		temp = abs(a[i] - a[j])
		if temp % m == 0 or pie % m == 0:
			pie = 0
			break
		pie = pie % m * temp % m % m
print(pie)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
else:
	p = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			p = p * abs(a[i] - a[j]) % m % m
			if p == 0:
				break
		if p == 0:
			break
	print(p)


def sign(num):
	if num < 0:
		return -1
	else:
		return 1
proisv = 1
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
b = list()
b.append(a[0] % m)
if n > m:
	print('0')
else:
	for i in range(n - 1):
		for j in range(i + 1, n):
			if i == 0:
				b.append(a[j] % m)
			if b[i] < b[j]:
				proisv *= b[i] - b[j] + m
			else:
				proisv *= b[i] - b[j]
		proisv = proisv % m
	print(proisv)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
newA = []
for j in range(len(a)):
	newA.append(a[j] % m)
if len(a) > len(set(newA)):
	print(0)
else:
	prod = 1
	for j in range(len(newA)):
		for k in range(j + 1, len(newA)):
			f = 1
			if a[j] < a[k]:
				f = -1
			prod = prod * f * (a[j] - a[k]) % m
	print(prod)


printn = lambda x: print(x, end='')
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 10 ** 18
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
(n, m) = inm()
a = inl()
if n > m:
	print(0)
	exit()
p = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		p = p * abs(a[i] - a[j]) % m
print(p)


(n, m) = list(map(int, input().split()))
As = list(map(int, input().split()))
if len(As) > m:
	print(0)
else:
	result = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			result = result * abs(As[j] - As[i]) % m
	print(result)


ok = [int(x) for x in input().split()]
n = ok[0]
m = ok[1]
r = [int(x) for x in input().split()]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(r[i] - r[j])
			ans %= m
	print(ans)


def impossible_cal(a, m):
	n = len(a)
	res = 1
	if n <= m:
		for i in range(n):
			for j in range(n):
				if j > i:
					res = res * abs(a[i] - a[j]) % m
		return res % m
	else:
		return 0

def read_line():
	(n, m) = input().split()
	a = input().split()
	a = [int(ch) for ch in a]
	print(impossible_cal(a, int(m)))
read_line()


import sys
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	exit(print(0))
result = 1
for i in range(n):
	for j in range(i + 1, n):
		result *= abs(a[i] - a[j])
		result %= m
print(result)


import math
import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, m) = ilele()
if n > m:
	print(0)
else:
	Ans = 1
	A = alele()
	for i in range(n):
		for j in range(i + 1, n):
			x = abs(A[i] - A[j]) % m
			Ans *= x
			Ans %= m
	print(Ans)


from math import factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')
import bisect

def main():
	(n, m) = RL()
	arr = list(RL())
	res = 1
	if n > m:
		print(0)
	else:
		for i in range(n):
			for j in range(i + 1, n):
				res *= abs(arr[i] - arr[j])
				res %= m
				if res == 0:
					break
		print(res % m)
main()


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(N, mod) = MAP()
A = LIST()
modA = [a % mod for a in A]
if len(modA) != len(set(modA)):
	print(0)
	exit()
ans = 1
for i in range(N):
	for j in range(i + 1, N):
		ans *= abs(A[i] - A[j])
		ans %= mod
print(ans)


from sys import stdin
(n, m) = list(map(int, stdin.readline().split(' ')))
A = list(map(int, stdin.readline().split(' ')))
if len(A) > m:
	print(0)
	exit()
A_dic = {}
for i in range(len(A)):
	if A[i] % m in A_dic:
		print(0)
		exit()
	else:
		A_dic[A[i] % m] = 1
result = 1
length = len(A)
for i in range(length):
	for j in range(i + 1, length):
		result = abs(A[i] - A[j]) * result
		result %= m
		if result == 0:
			print(0)
			exit()
print(result)


from math import *
(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(a[i] - a[j])
			ans %= m
	print(ans)


from functools import reduce
from itertools import combinations
(N, MOD) = map(int, input().split())
A = list(map(int, input().split()))

def solve(A, MOD):
	if len(A) > MOD:
		return 0
	return reduce(lambda x, y: x * y % MOD, (abs(a - b) % MOD for (a, b) in combinations(A, 2)))
print(solve(A, MOD) % MOD)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 1
l.sort()
if n > m:
	print(0)
else:
	for i in range(0, n):
		for j in range(i + 1, n):
			c = c * abs(l[j] - l[i])
			if c == 0:
				break
			c = c % m
		if c == 0:
			break
	print(c)


(n, m) = [int(i) for i in input().split()]
lst = list(map(int, input().split()))
product = 1
if n > m:
	print(0)
else:
	for i in range(len(lst) - 1):
		for j in range(i + 1, len(lst)):
			product = product * abs(lst[i] - lst[j])
			product = product % m
	print(product)


(N, M) = list(map(int, input().split()))
alist = list(map(lambda x: int(x), input().split()))
if M < N:
	total = 0
else:
	total = 1
	for n in range(N - 1):
		aref = alist[n]
		for k in range(n + 1, N):
			total = total * abs(aref - alist[k]) % M
			if total % M == 0:
				break
		if total % M == 0:
			break
print(total)


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
(n, m) = R()
a = L()
if n > m:
	exit(print(0))
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= m
print(ans)


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [0 for i in range(m)]
c = [0 for i in range(m)]
for i in a:
	b[i % m] += 1
	c[i % m] = i
for i in b:
	if i > 1:
		print(0)
		exit()
tot = 1
for i in range(m):
	if b[i] == 1:
		for j in range(i + 1, m):
			if b[j] == 1:
				tot = tot * abs(c[j] - c[i]) % m
print(tot % m)


import sys
from collections import Counter as cc
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
l = I()
p = [i % m for i in l]
if len(set(p)) != n:
	print(0)
else:
	an = 1
	for i in range(n):
		for j in range(i + 1, n):
			an = an * abs(l[i] - l[j]) % m
	print(an % m)


(n, m) = input().split()
(n, m) = (int(n), int(m))
if m < n:
	print(0)
	exit(0)
l = [int(i) for i in input().split()]
product = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		product = product * abs(l[i] - l[j]) % m
	if product == 0:
		break
print(product)


import sys
import bisect
import heapq
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(n, k) = Ri()
a = Ri()
if k >= n:
	ans = 1
	for i in range(len(a)):
		for j in range(i + 1, len(a)):
			ans *= abs(a[i] - a[j])
			ans = ans % k
	print(ans)
else:
	print(0)


n = list(map(int, input().split()))
a = list(map(int, input().split()))
aux = 1
if n[0] > n[1]:
	print(0)
else:
	for i in range(n[0]):
		for k in range(i + 1, n[0]):
			aux = aux * abs(a[i] - a[k])
			aux = aux % n[1]
	print(aux)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
if n > m:
	print('0')
else:
	a.sort()
	i = n
	s = 1
	while i > 0:
		i -= 1
		j = 0
		while j < i:
			s = s * (a[i] - a[j]) % m
			j = j + 1
	print(s)


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def si():
	return input()

def prefix_sum(arr):
	r = [0] * (len(arr) + 1)
	for (i, el) in enumerate(arr):
		r[i + 1] = r[i] + el
	return r

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
t = 1
for _ in range(t):
	(n, m) = li()
	a = li()
	if n <= m:
		res = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				res *= abs(a[i] - a[j])
				res %= m
		print(res % m)
	else:
		print(0)


from itertools import groupby
(n, m) = map(int, input().split())
a1 = list(map(int, input().split()))
a = [el for (el, _) in groupby(a1)]
if n > m or len(a) != len(a1):
	exit(print(0))
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= m
print(ans)


from collections import *
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			s = abs(a[i] - a[j])
			ans *= s
			ans %= m
	print(ans)


for _ in range(1):
	(n, m) = map(int, input().split())
	li = list(map(int, input().split()))
	if n > 1005:
		print(0)
	else:
		ans = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				ans *= abs(li[i] - li[j])
				ans %= m
				if ans == 0:
					break
			if ans == 0:
				break
		print(ans)


(a, b) = map(int, input().split())
l = list(map(int, input().split()))
ans = 1
if a > b:
	print(0)
	exit()
for i in range(a):
	for j in range(i + 1, a):
		ans *= pow(abs(l[j] - l[i]), 1, b)
		ans = pow(ans, 1, b)
		if pow(ans, 1, b) == 0:
			print(0)
			exit()
print(pow(ans, 1, b))


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
(n, m) = rint()
a = list(rint())
ans = 0
if n <= m:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
print(ans)


from itertools import combinations
(n, m) = map(int, filter(None, input().split(' ')))
arr_a = list(map(int, filter(None, input().split(' '))))
arr_b = []
if n <= m:
	mul = 1
	for i in range(0, len(arr_a)):
		for j in range(i + 1, len(arr_a)):
			mul = mul * abs(arr_a[i] - arr_a[j]) % m
			mul = mul % m
else:
	mul = 0
print(mul)


(n, mod) = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
ans = 1
if n <= 1002:
	for i in range(n):
		for i2 in range(i - 1, -1, -1):
			ans = ans * (x[i] - x[i2]) % mod
else:
	ans = 0
print(ans)


import sys
input = sys.stdin.readline

def main():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if n > m:
		print(0)
		exit()
	s = 1
	for j in range(n):
		for i in range(j + 1, n):
			s *= a[j] - a[i]
			s %= m
			if s == 0:
				break
	print(s)
main()


(n, md) = map(int, input().split())
a = list(map(int, input().split()))
if n > md:
	print('0')
else:
	answer = 1
	for i in range(n):
		for j in range(i + 1, n):
			answer = answer * abs(a[i] - a[j]) % md
	print(answer)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
if m < n:
	print(0)
	exit()
b = set(a)
if sum(a) != sum(b):
	print(0)
	exit()
prod = 1
for i in range(n):
	for j in range(i + 1, n):
		prod *= abs(a[i] - a[j])
		prod %= m
print(prod)


(n, mod) = map(int, input().split())
A = list(map(int, input().split()))
if n > mod:
	print(0)
	exit()
ans = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		ans *= abs(A[j] - A[i])
		ans %= mod
ans %= mod
print(ans)


from itertools import groupby
k = [int(i) for i in input().split()]
n = k[0]
m = k[1]
mas1 = [int(i) for i in input().split()]
mas = [el for (el, _) in groupby(mas1)]
if len(mas) != len(mas1) or n > m:
	print(0)
else:
	pro = 1
	wow = {}
	for i in range(n):
		bol = 0
		for j in range(n):
			if j < i:
				v = abs(mas[i] - mas[j])
				if v == 0:
					print(0)
					bol = 1
					break
				if v not in wow:
					wow.get(v)
					wow[v] = 1
				else:
					wow[v] = wow[v] + 1
			else:
				break
		if bol == 1:
			break
	if bol == 0:
		for (i, j) in wow.items():
			pro *= pow(i, j, m)
			pro %= m
		print(pro)


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
(n, m) = map(int, input().split())
li = [int(x) for x in input().split()]
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(li[i] - li[j]) % m
	print(ans)


from sys import stdin
from collections import defaultdict

def foo(n, m, nums):
	d = defaultdict(int)
	for num in nums:
		d[num % m] += 1
	for x in d.values():
		if x > 1:
			return 0
	ans = 1
	for i in range(n - 1):
		for g in range(i + 1, n):
			ans = ans * abs(nums[i] - nums[g]) % m
	return ans
(n, m) = map(int, stdin.buffer.readline().split())
nums = list(map(int, stdin.buffer.readline().split()))
print(foo(n, m, nums))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
A = tuple(map(int, input().split()))
L = [[] for i in range(m)]
for a in A:
	L[a % m].append(a)
for i in range(m):
	if L[i] == []:
		continue
	if len(L[i]) >= 2:
		print(0)
		sys.exit()
ANS = 1
for i in range(m):
	if L[i] == []:
		continue
	for j in range(i + 1, m):
		if L[j] == []:
			continue
		ANS = ANS * abs(L[j][0] - L[i][0]) % m
print(ANS)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
rem = [0 for i in range(m)]
f = False
for i in range(n):
	if rem[a[i] % m] == 0:
		rem[a[i] % m] = 1
	else:
		f = True
		break
if f:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans = ans * abs(a[i] - a[j]) % m
	print(ans)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, m) = I()
a = I()
a.sort(reverse=True)
ans = 1
s = set()
for i in a:
	s.add(i % m)
if len(s) != n:
	print(0)
	exit()
for i in range(n):
	for j in range(i + 1, n):
		ans *= a[i] - a[j]
		ans %= m
print(ans)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
(n, m) = inputnums()
a = inputlist()
if m < n:
	print(0)
else:
	ans = 1
	for i in range(0, n - 1):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)


import sys
(N, M) = map(int, input().split())
X = map(int, input().split())
d = [0] * M
d2 = [-1] * M
for x in X:
	d[x % M] += 1
	if d2[x % M] != -1:
		print(0)
		sys.exit()
	d2[x % M] = x
r = 1
for i in range(1, M):
	for j in range(M):
		k = (j + i) % M
		if d[j] == 0 or d[k] == 0:
			continue
		if d2[j] < d2[k]:
			t = i % M
			r = r * t % M
print(r)


from sys import stdin, stdout
from collections import Counter
from collections import defaultdict
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
ai = lambda : list(map(int, stdin.readline().split()))
ei = lambda : map(int, stdin.readline().split())
ip = lambda : int(stdin.readline().strip())
(n, m) = ei()
li = ai()
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			ans *= abs(li[i] - li[j])
			ans %= m
	print(ans)


from collections import Counter, defaultdict, deque
import heapq as hq
from itertools import count, islice
import math
import sys
input = sys.stdin.readline
(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
if n > m:
	print(0)
else:
	prod = 1
	for i in range(n):
		for j in range(i + 1, n):
			prod *= abs(arr[i] - arr[j])
			prod %= m
	print(prod)


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def solution(a, n, m):
	if n > m:
		return 0
	sol = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			sol *= abs(a[i] - a[j])
			sol %= m
	return sol

def main():
	T = 1
	for i in range(T):
		(n, m) = ria()
		a = ria()
		x = solution(a, n, m)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


def solve():
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	if n > m:
		print('0')
		exit(0)
	else:
		res = 1
		for i in range(n):
			for j in range(i + 1, n, 1):
				res = res * abs(arr[i] - arr[j]) % m
		print(res)
solve()


import collections as cc
import math as mt
import sys
I = lambda : list(map(int, input().split()))
(n, m) = I()
a = I()
su = 1
if n > m:
	print(0)
else:
	for i in range(n):
		for j in range(i + 1, n):
			su *= abs(a[i] - a[j]) % m
			su %= m
	print(su)


def solve():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	if n > m:
		return 0
	numbers = sorted(list(map(int, input().split())), reverse=True)
	remainders = list((x % m for x in numbers))
	result = 1
	for i in range(n):
		for j in range(i + 1, n):
			a = remainders[i]
			b = remainders[j]
			if a >= b:
				result *= a - b
			else:
				result *= a + m - b
		result = result % m if result >= 0 else -result % m
	return result
print(solve())


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = mi()
a = li()
res = 1
if n > m:
	print(0)
else:
	for i in range(n - 1):
		for j in range(i + 1, n):
			res *= abs(a[i] - a[j])
			res %= m
	print(res)


import sys
(n, m) = list(map(int, sys.stdin.readline().rstrip().split()))
a = list(map(int, sys.stdin.readline().rstrip().split()))
if n <= m:
	re = 1
	for i in range(n):
		for j in range(i + 1, n):
			re *= abs(a[i] - a[j])
			if re > m:
				re %= m
	print(re % m)
else:
	print(0)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
val = 1
if n > m:
	exit(print(0))
for i in range(n):
	for j in range(i + 1, n):
		val *= abs(arr[i] - arr[j])
		val %= m
print(val)


def solve(n, m, a):
	if m < n:
		return 0
	r = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			r = r * abs(a[i] - a[j]) % m
	return r
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
r = solve(n, m, a)
print(r)


(n, m) = map(int, input().split())
List = list(map(int, input().split()))
summ = 1
if n > m:
	print(0)
else:
	for i in range(n):
		for j in range(i + 1, n):
			summ = summ * abs(List[i] - List[j])
			summ = summ % m
	print(summ)


(n, m) = [int(x) for x in input().split()]
if n > m:
	print(0)
else:
	l = [int(x) for x in input().split()]
	l = list(sorted(l))
	res = 1
	for i in range(n):
		for j in range(i + 1, n):
			res *= l[j] - l[i]
			res %= m
	print(res)


import sys, re, math
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log2, floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
INF = float('inf')
mod = 10 ** 9 + 7
(n, m) = MAP()
a = LIST()
if n > m:
	exit(print(0))
a.sort()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs((a[j] % m - a[i] % m) % m) % m
		ans %= m
print(ans % m)


from collections import defaultdict
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
s = set([])
d = defaultdict(int)
flag = 1
ans = 1
for i in l:
	d[i % m] += 1
	if d[i % m] >= 2:
		flag = 0
		ans = 0
	s.add(i)
if flag:
	s = list(s)
	s.sort()
	for i in range(len(s)):
		for j in range(i + 1, len(s)):
			ans *= (s[j] - s[i]) % m
			ans %= m
			if ans == 0:
				break
print(ans)


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
moduler = [0] * 1001
for i in range(n):
	moduler[arr[i] % m] += 1
	tof = True
for i in range(1001):
	if moduler[i] > 1:
		tof = False
if tof == False:
	print(0)
else:
	ans = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			tmp = 0
			if arr[i] < arr[j]:
				tmp = arr[j] - arr[i]
			else:
				tmp = arr[i] - arr[j]
			ans *= tmp
			ans %= m
	print(ans % m)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
(n, mod) = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
ans = 1
if n > mod:
	print(0)
else:
	for i in range(n):
		for j in range(i):
			ans *= abs(nums[i] - nums[j])
			ans %= mod
	print(ans)


(n, k) = map(int, input().split())
ans = 1
list1 = list(map(int, input().split()))
if n > k:
	print(0)
else:
	for i in range(n):
		for j in range(i):
			ans = ans % k * abs(list1[i] - list1[j]) % k % k
	print(ans)


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math

def solve():
	(N, M) = getInts()
	A = getInts()
	if N > M:
		return 0
	counts = col.defaultdict(int)
	for a in A:
		counts[a] += 1
		if counts[a] > 1:
			return 0
	arr = []
	for key in counts:
		arr.append(key)
	ans = 1
	for i in range(len(arr)):
		for j in range(i + 1, len(arr)):
			ans *= abs(arr[i] - arr[j])
			ans %= M
	return ans
print(solve())


def f():
	(n, m) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	if n > m:
		return 0
	ans = 1
	for i in range(n):
		for j in range(i):
			ans *= abs(A[i] - A[j])
			ans %= m
	return ans
print(f())


def process(a, m):
	n = len(a)
	if n > m:
		return 0
	remainders = set((k % m for k in a))
	if len(remainders) < n:
		return 0
	res = 1
	for i in range(n):
		for j in range(i + 1, n):
			res = res * abs(a[i] - a[j]) % m
	return res
(n, m) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
print(process(a, m))


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import io
import os

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, m) = rinput()
a = rinput()
if n > m:
	print(0)
else:
	a = sorted(a, reverse=True)
	d = defaultdict(int)
	ans = 1
	for i in a:
		d[i % m] += 1
	for i in a:
		for j in range(m):
			d[i % m] -= 1
			want = (i - j) % m
			if d[want] > 0:
				ans = ans * pow(j, d[want], m) % m
	print(ans)


(n, m) = map(int, input().split())
f = list(map(int, input().split()))[:n]
p = 1
for i in f:
	i = i % m
if n > m:
	print(0)
	exit()
else:
	for j in range(n):
		for k in range(j + 1, n):
			p = p * abs(f[j] - f[k]) % m % m
	print(p % m)
	exit()


import os, sys
if os.path.exists('inp.txt'):
	sys.stdin = open('inp.txt', 'r')

def _():
	return sys.stdin.readline()

def __():
	return sys.stdin.readline().split()
maxn = 2005
dd = [0 for i in range(maxn)]
(n, m) = map(int, __())
a = list(map(int, __()))
for i in a:
	dd[i % m] += 1
for i in range(m):
	if dd[i] > 1:
		print(0)
		exit(0)
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		ans *= abs(a[i] - a[j])
		ans %= m
print(ans)


import sys
import math
import bisect

def solve(A, m):
	n = len(A)
	if n >= m + 1:
		return 0
	val = 1
	for i in range(n):
		for j in range(i + 1, n):
			val *= abs(A[i] - A[j])
			val %= m
	return val

def main():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	ans = solve(A, m)
	print(ans)
main()


(n, m) = map(int, input().split())
lista = []
lista = list(map(int, input().split()))
tot = 1
if n > m:
	print(0)
else:
	for i in range(0, len(lista)):
		for j in range(i + 1, len(lista)):
			tot = tot * abs(lista[i] - lista[j]) % m
	print(tot)


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
if n > m:
	print(0)
else:
	res = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			res = res * abs(l[i] - l[j]) % m
	print(res % m)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv2(N, M, A):
	ans = 1
	for (i, j) in combinations(range(N), r=2):
		ans *= abs(A[i] - A[j])
		ans %= M
	return ans

@mt
def slv(N, M, A):
	ac = Counter([a % M for a in A])
	for (k, v) in ac.items():
		if v < 2:
			continue
		else:
			return 0
	ans = 1
	for (i, j) in combinations(range(N), r=2):
		ans *= abs(A[i] - A[j])
		ans %= M
	return ans

def main():
	(N, M) = read_int_n()
	A = read_int_n()
	print(slv(N, M, A))
main()


s = input().split()
n = int(s[0])
m = int(s[1])
num = input().split()
for i in range(len(num)):
	num[i] = int(num[i])
sum = 1
result = 0
if n > m:
	print('0')
else:
	for i in range(n - 1):
		for z in range(i + 1, len(num)):
			sum = sum * abs(num[i] - num[z]) % m
	result = sum % m
	print(result)


def process(A, m):
	A = sorted(A)
	answer = 1
	n = len(A)
	if n - 10 <= m:
		for i in range(n):
			for j in range(i + 1, n):
				answer = answer * (A[j] - A[i])
				answer = answer % m
				if answer == 0:
					return 0
		return answer
	else:
		return 0
(n, m) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
print(process(A, m))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
if n > m:
	print(0)
else:
	new_arr = []
	for x in range(n):
		for y in range(x + 1, n):
			new_arr.append(abs(arr[x] - arr[y]) % m)
	ans = 1
	for each in new_arr:
		ans = ans * each % m
	print(ans)


import sys
input = sys.stdin.readline
(n, mod) = map(int, input().split())
a = list(map(int, input().split()))
nest = [0 for _ in range(mod)]
for x in a:
	nest[x % mod] += 1
if max(nest) > 1:
	print(0)
	exit()
ans = 1
for i in range(n):
	for j in range(i + 1, n):
		tmp = abs(a[j] - a[i])
		ans *= tmp
		ans %= mod
print(ans)


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
already = set()
P = []
iszero = False
for a in A:
	a %= M
	if a in already:
		iszero = True
		break
	already.add(a)
	P.append(a)
if iszero:
	print(0)
else:
	ans = 1
	for (i, p) in enumerate(P):
		for j in range(i + 1, len(P)):
			ans = ans * (P[j] - p) % M
	print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve():
	(n, m) = map(int, input().split())
	mod = m
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	a = [i % mod for i in a]
	if n > m:
		ans = 0
	else:
		b = [0] * m
		c = [0] * m
		for ai in a:
			for (j, bj) in enumerate(b):
				if bj:
					k = j - ai
					if k < 0:
						k += mod
					c[k] += bj
			b[ai] += 1
		ans = 1
		for (i, cnt) in enumerate(c):
			ans *= pow(i, cnt, mod)
			ans %= mod
	print(ans)
solve()


(N, M) = map(int, input().split())
L = list(map(int, input().split()))
if N > M:
	print(0)
else:
	ret = 1
	for i in range(N):
		for j in range(i):
			ret = ret * abs(L[i] - L[j]) % M
	print(ret)


import sys, math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = 1
for tt in range(t):
	(n, m) = invr()
	a = inlt()
	q = 1
	if n > m or len(set(a)) < len(a):
		q = 0
	else:
		for i in range(len(a)):
			for j in range(i + 1, n):
				q = q * abs(a[i] - a[j]) % m
	print(q)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
v = [0 for i in range(m)]
d = False
for i in a:
	if v[i % m]:
		print(0)
		d = True
		break
	v[i % m] = 1
if not d:
	r = 1
	for i in range(n):
		for j in range(i + 1, n):
			r = r * abs(a[i] - a[j]) % m
	print(r)


(n, mod) = list(map(int, input().split()))
arr = list(map(int, input().split()))
if n <= mod:
	m = 1
	for i in range(n - 1):
		for g in range(i + 1, n):
			m *= abs(arr[i] - arr[g])
			m %= mod
	print(m)
else:
	print(0)


from sys import stdin
input = stdin.readline
(n, m) = map(int, input().split())
a = sorted(map(int, input().split()))
if n > m:
	print(0)
	exit()
f = 1
for i in range(n):
	for j in range(i):
		f = f * (a[i] - a[j]) % m
print(f)


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, m) = M()
a = LI()
if n > m:
	print(0)
else:
	ans = 1
	for i in range(n):
		for j in range(i + 1, n):
			ans *= abs(a[i] - a[j])
			ans %= m
	print(ans)


import sys
import math

def read_line():
	return sys.stdin.readline()[:-1]

def read_int():
	return int(sys.stdin.readline())

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
(n, m) = read_int_line()
a = read_int_line()
if n > 1000:
	print(0)
else:
	p = 1
	for i in range(n):
		for j in range(i + 1, n):
			p = p % m * abs(a[i] - a[j]) % m % m
	print(p)


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(n, m) = sp()
arr = l()
if n > m:
	out('0')
	exit()
arr.sort()
pr = 1
for i in range(n - 1):
	for j in range(i + 1, n):
		pr = pr * (arr[j] - arr[i]) % m
out(str(pr))


from functools import reduce
from itertools import combinations

def go():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	if len(set((aa % m for aa in a))) < n:
		return 0
	else:
		res = reduce(lambda a, b: a * abs(b[0] - b[1]) % m, combinations(a, 2), 1)
		return res
print(go())


(n, modulo) = [int(x) for x in input().split()]
array = sorted([int(x) for x in input().split()])
if n <= modulo:
	total = 1
	for i in range(n - 1):
		for j in range(i + 1, n):
			total *= (array[j] % modulo - array[i] % modulo) % modulo
			total = total % modulo
	print(total % modulo)
else:
	print(0)


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
(n, mod) = intsput()
a = list(intsput())
if n > mod:
	print(0)
else:
	mult = 1
	for i in range(n):
		for j in range(i + 1, n):
			mult *= abs(a[i] - a[j]) % mod
			mult %= mod
	print(mult)


(n, m) = map(int, input().split())
a = [int(x) for x in input().split()]
mod = [0] * m
if n > m:
	print(0)
else:
	for x in a:
		mod[x % m] += 1
	maxi = max(mod)
	if maxi > 1:
		print(0)
	else:
		ans = 1
		for i in range(n - 1):
			for j in range(i + 1, n):
				ans = ans * abs(a[j] - a[i]) % m
		print(ans)


ans = 1
B = []
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
for i in range(len(A)):
	B.append(A[i] % m)
B.sort()
for i in range(len(A) - 1):
	if B[i] == B[i + 1]:
		ans = 0
if ans == 1:
	for i in range(len(A)):
		for j in range(i):
			ans *= abs(A[i] - A[j]) % m
			ans = ans % m
print(ans)