PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000012. Tích hiệu theo mô-đun (Kuroni and Impossible Calculation)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tích hiệu theo mô-đun (Kuroni and Impossible Calculation)

Kuroni and Impossible Calculation

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn nonnegative integers a1,…,ana_1,\ldots,a_n and positive modulus mm, compute the product of ∣ai−aj∣|a_i-a_j| over all pairs i<ji<j, modulo mm.

Input

First line: n,mn,m. Second line: nn values aia_i.

Output

Print the product modulo mm.

Subtasks

  • Subtask 1 (20 points): 2≤n≤102 \le n \le 10; 1≤m≤201 \le m \le 20; 0≤ai≤1000 \le a_i \le 100
  • Subtask 2 (30 points): 2≤n≤2002 \le n \le 200; 1≤m≤2001 \le m \le 200; 0≤ai≤1060 \le a_i \le 10^{6}
  • Subtask 3 (50 points): 2≤n≤2⋅1052 \le n \le 2\cdot 10^{5}; 1≤m≤10001 \le m \le 1000; 0≤ai≤1090 \le a_i \le 10^{9}

Examples

Input

2 10
8 5

Output

3

Explanation

There is only one pair, whose absolute difference is 33, so the result modulo 1010 is 33.