Under construction

Still being built. Things may change

Geometric Progression

Time limit1sMemory limit1024 MB

Summary
Count index triples i<j<k in a strictly increasing array with values up to 1e6 where a_i times a_k equals a_j squared.
Level

Medium5 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

bobo loves geometric progressions! So he wants to know the number of geometric progressions of length 33 in a sequence a1,a2,…,ana_1, a_2, \dots, a_n.

That is to say, count the number of (i,j,k)(i, j, k) where i<j<ki < j < k and ai×ak=aj2a_i \times a_k = a_j^2.

Input

The first line contains an integer nn (1≤n≤10000001 \leq n \leq 1000000).

The second line contains nn integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤a1<a2<⋯<an≤10000001 \leq a_1 < a_2 < \dots < a_n \leq 1000000).

Output

A single integer denotes the number of geometric progressions.

Examples2

  1. Example 1

    Input
    3
    1 2 4
    
    Expected output
    1
    
  2. Example 2

    Input
    4
    1 2 4 8
    
    Expected output
    2