Ordered Triplets

3.7

11 votes
Problem

You are given an array A of size N. You have to find out number of ordered triplet (i,j,k) such that abs(A[i]A[j])=abs(A[j]A[k]) where abs represents absolute value.

Input:

First Line contains N representing size of array.

Next line contains N space separated integers representing array A.

Output:

Print the number of ordered triplets satisfying above conditioned modulo 109+7 as answer will be large.

Constraints:

1<=N<=105

1<=A[i]<=103

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?