#P9880. Disproving the Inequality

    ID: 23025 Type: Default 1000ms 256MiB

Disproving the Inequality

Disproving the Inequality

Professor Pang has built his famous coding team and gathered hundreds of pupils aiming for a gold medal in ICPC. One of his students, however, believes that for any integers \(a\) and \(b\), it always holds that \(a \times b \ge a + b\). To disprove this claim, Professor Pang has written \(n\) numbers \(a_1, a_2, \ldots, a_n\) on a piece of paper. Your task is to count the number of pairs \((a_i, a_j)\) (with \(1 \le i < j \le n\)) that satisfy the inequality:

\(a_i \times a_j < a_i + a_j\)

Note: The input consists of an integer \(n\) followed by a line of \(n\) integers, and the output is a single integer representing the count of valid pairs.

inputFormat

The first line contains a single integer \(n\) — the number of numbers written on the paper.

The second line contains \(n\) space-separated integers \(a_1, a_2, \ldots, a_n\).

outputFormat

Output a single integer, the number of pairs \((a_i, a_j)\) (with \(1 \le i < j \le n\)) satisfying \(a_i \times a_j < a_i + a_j\).

sample

4
1 2 3 1
5