IPOh No
EarthX is a space company owned by billionaire TomLon Tusk that is seeking to IPO at an astonishing valuation of ~1.75 trillion. They are seeking inclusion in the Nasdaq 100 as part of their listing, allowing pension funds and such to provide sweet exit liquidity to Tusk and his friends.
As part of the preparation for IPO, TomLon is driving heavy cost-cutting, involving laying off 1,000,000 workers, tightening up supply chains, etc. One of EarthX's primary products is GroundLink, a satellite WiFi service. They maintain some ground towers, but these towers interfere with each other, so they want you to calculate the total instability of the system using some certain formulas.
There are ground towers at integer coordinates
. Each tower emits a signal, and the interference between two towers at positions
,
is given as
The total system instability is defined as:
i.e., the interference between every (unordered) pair of towers.
Can you calculate this metric for them, so they can use it to cut costs and provide TomLon his sweet golden parachute? The researchers also asked you to output the stability modulo , as they are running on ancient 32-bit systems and don't want your value to blow up their servers.
Input
The first line contains an integer
, the number of signal towers.
The second line contains space-separated integers
.
Output
Output the total system instability, modulo .
Example
Input 1
3
1 2 3
Output 1
10
We can just enumerate all pairs
:
:
:
So the result is .
Input 2
4
-2 -1 0 2
Output 2
48
:
:
:
:
:
:
The result is thus
Input 3
4
0 5 0 0
Output 3
90
Comments