P7517 [NOI Qualifier Joint Contest 2021 B Volume] Number Pairs.
Description
Given $n$ positive integers $a_i$, please find how many ordered pairs $(i, j)$ satisfy $1 \le i \le n$, $1 \le j \le n$, $i \ne j$, and $a_i$ is a multiple of $a_j$.
Input Format
The first line contains an integer $n$, representing the number of integers.
The second line contains $n$ integers, representing $a_i$.
Output Format
Output one line with one integer, representing the answer.
Explanation/Hint
For $40\%$ of the testdata, $n \le 1000$.
For $70\%$ of the testdata, $1 \le a_i \le 5 \times {10}^3$.
For $100\%$ of the testdata, $2 \le n \le 2 \times {10}^5$, $1 \le a_i \le 5 \times {10}^5$.
Translated by ChatGPT 5