eolymp
bolt
Try our new interface for solving problems
Problems

Product of differences

Product of differences

Array of integers $a_1, a_2, ..., a_n$ is given. Find the product $$ \prod_{\substack{1 \le i < j \le n}}|a_i − a_j| $$ If you are not familiar with short notation, this product equals to $$ |a_1 − a_2| * |a_1 − a_3| * ... * |a_1 − a_n| * |a_2 − a_3| * |a_2 − a_4| * ... * |a_2 − a_n| * ... * |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$. As the result will be very big, find it modulo $m$. \InputFile First line contains two integers $n\:(n \le 10^5)$ and $m\:(m \le 1000)$. Next line contains $n$ integers $a_1, a_2, ..., a_n\:(0 \le a_i \le 10^9)$. \OutputFile Print the value of the product modulo $m$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5 123
4 6 12 41 71
Output example #1
102