Problem Statement
Let’s take a prime P=200,003. You are given N integers A1,A2,ldots,AN. Find the sum of ((AicdotAj)bmodP) over all Ncdot(N−1)/2 unordered pairs of elements (i<j).
Please note that the sum isn't computed modulo P.
Constraints
- 2leqNleq200,000
- 0leqAi<P=200,003
- All values in input are integers.
Input is given from Standard Input in the following format.
N
A1 A2 cdots AN
Output
Print one integer — the sum over ((AicdotAj)bmodP).
4
2019 0 2020 200002
Sample Output 1
474287
The non-zero products are:
- 2019cdot2020bmodP=78320
- 2019cdot200002bmodP=197984
- 2020cdot200002bmodP=197983
So the answer is 0+78320+197984+0+0+197983=474287.
5
1 1 2 2 100000
Sample Output 2
600013