close

ABCDEF - ABCDEF


You are given a set S of integers between -30000 and 30000 (inclusive).

Find the total number of sextuples (a, b, c, d, e, f): a, b, c, d, e, f ∈ S; d ≠ 0  that satisfy:

Image

Input

The first line contains integer N (1 ≤ N ≤ 100), the size of a set S.

Elements of S are given in the next N lines, one integer per line. Given numbers will be distinct.

Output

Output the total number of plausible sextuples.

Examples

Input:
1
1

Output:
1
Input:
2
2
3

Output:
4
Input:
2
-1
1

Output:
24
Input:
3
5
7
10

Output:
10

hide comments
Image siddharthvp: 2019-07-30 18:44:26

Are a,b,c,d,e,f distinct?

Image divergent42: 2019-07-04 14:54:42

Easy question..lower bound and upper bound is the key to solve this

Image anshika_85: 2019-07-04 07:03:01

nice!!!

Image yashranjan74: 2019-06-20 08:55:01

Just make sure to check for d==0 case and maintain complexity of O(N^3) at max.

Image hetp111: 2019-05-31 15:19:16

sexy

Image Jumpy: 2019-04-21 16:46:05

The above equations can be written as:

a * b + c = (f+e) *d , with exception d can't be 0 'zero'. Now, the complexity can be reduced to N^3.

Image gs959_me: 2019-04-10 18:45:16

while using unordered map initialize the size as N^3, in order to avoid TLE

Image josecaz1: 2019-04-07 22:51:20

Don't forget to use unordered_map! Cost me 1 WA

Image starun8795: 2019-01-16 14:15:13

In 11th test case d=0 so don't forget to apply a check.

Image md_meraj1319: 2018-12-18 19:05:05

TO SOLVE THE PROBLEM ALL SEXTUPLES SHOULD BE GENERATED OR NOT?


Added by:Luka Kalinovcic
Date:2009-07-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:own problem