#P7517. Counting Multiples Pair

    ID: 20712 Type: Default 1000ms 256MiB

Counting Multiples Pair

Counting Multiples Pair

Given n positive integers \(a_i\), your task is to count the number of ordered pairs \((i, j)\) such that \(1 \leq i, j \leq n\), \(i \neq j\) and \(a_i\) is a multiple of \(a_j\) (i.e. \(a_i \mod a_j = 0\)).

Note: The pair \((i, j)\) is considered different from \((j, i)\) if \(i \neq j\).

inputFormat

The input consists of two lines:

  • The first line contains a single integer \(n\) (the number of integers).
  • The second line contains \(n\) positive integers separated by spaces.

outputFormat

Output a single integer representing the number of pairs \((i, j)\) satisfying the given conditions.

sample

3
1 2 3
2