Multiplication
InterviewTime limit2sMemory limit1024 MB
Count the triples i < j < k with A[i] * A[j] = A[k] in an array of at most 100 positive integers.
- Level
Easy3 of 10
- Topics
- Brute force, Array, Implementation
- Solved
- No attempts yet
Problem
Aoi, a student at JOI High School, found a scroll in the library. The scroll has N integers written in a row, and the i-th number from the left (1 ≦ i ≦ N) is Ai.
Looking at the scroll, Aoi wondered: "If I choose 3 of these N integers and call them x, y, z in order from left to right, how many ways are there to choose integers such that x × y = z?"
Given the N integers written on the scroll, write a program to find the answer to Aoi's question.
Input
The input is given from standard input in the following format.
N
A1 A2 … AN
Output
Print the answer to Aoi's question to standard output in 1 line.
Constraints
3 ≦ N ≦ 100.1 ≦ Ai ≦ 999(1 ≦ i ≦ N).- All input values are integers.