P9148 Division Problem.
Description
Given a set $a$ of size $n$, all elements are guaranteed to be distinct and are all positive integers.
If we pick three elements $a, b, c$ from it **in order**, then there are $n \cdot (n-1) \cdot (n-2)$ different ways to choose.
Now for one choice $(a,b,c)$, define its weight as $\Bigl\lfloor\dfrac{a}{b}\Bigr\rfloor\Bigl\lfloor\dfrac{a}{c}\Bigr\rfloor\Bigl\lfloor\dfrac{b}{c}\Bigr\rfloor$.
You need to compute the sum of weights over all choices. You only need to output this sum modulo $2^{32}$.
Note: $\lfloor a\rfloor$ denotes the greatest integer not greater than $a$. For example, $\lfloor 2.4\rfloor=2$ and $\lfloor 5\rfloor=5$.
Input Format
The first line contains a positive integer $n$, the length of the sequence.
The second line contains $n$ positive integers $a_1, a_2, \ldots, a_n$. Each number describes one element of the set $a$, and all these numbers are distinct.
Output Format
Output one line with one integer, the answer modulo $2^{32}$.
Explanation/Hint
**[Sample Explanation #1]**
For sample #1, the only choices with non-zero weight are:
- $(3,2,1)$, with weight $6$.
- $(4,2,1)$, with weight $16$.
- $(4,3,1)$, with weight $12$.
- $(4,3,2)$, with weight $2$.
Therefore, the answer for sample #1 is $6+16+12+2=36$.
---
**[Constraints]**
For $100\%$ of the testdata, $1 \le n, a_i \le 5000$.
**This problem uses bundled tests.**
|Subtask|$n$|Special Property|Points|
|-|-|-|-|
|1|$=3$||$10$|
|2|$\le 300$||$20$|
|3|$\le 2000$||$20$|
|4||A|$20$|
|5|||$30$|
Special Property A: it is guaranteed that $a_i=i$.
---
**[Hint]**
In this problem, most algorithms have small constant factors. Please trust your time complexity.
Translated by ChatGPT 5