#P9148. Triplets Weight Sum
Triplets Weight Sum
Triplets Weight Sum
You are given a set of n distinct positive integers. From this set, we take three elements a, b, c in order. There are a total of n \cdot (n-1) \cdot (n-2) different ways to choose such an ordered triplet.
For a chosen triplet \((a, b, c)\), its weight is defined as
\[ \left\lfloor \frac{a}{b} \right\rfloor \cdot \left\lfloor \frac{a}{c} \right\rfloor \cdot \left\lfloor \frac{b}{c} \right\rfloor, \]where \(\lfloor x \rfloor\) denotes the greatest integer less than or equal to \(x\) (for example, \(\lfloor 2.4 \rfloor = 2\) and \(\lfloor 5 \rfloor = 5\)). Note that if any of the three factors is zero, then the weight is zero. In fact, since all numbers are positive and distinct, a non-zero product is obtained if and only if \(a > b > c\).
Your task is to compute the total sum of the weights for all possible ordered triplets, and output the result modulo \(2^{32}\) (i.e. modulo 4294967296).
inputFormat
The input consists of two lines:
- The first line contains a single integer n representing the number of elements in the set.
- The second line contains n space-separated positive integers which are guaranteed to be distinct.
outputFormat
Output a single integer, which is the total sum of weights of all ordered triplets taken modulo 232.
sample
3
1 2 3
6