ABCDEF - ABCDEF


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

Find the total number of sextuples  that satisfy: 

 

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
ramini1996: 2018-02-04 11:48:40

Rearrange the given expression as [ (a*b)+c = d*(e+f) ]. Now, store possible values for LHS in a vector(say v1) and possible values for RHS in another vector(say v2). Now, sort v2 and iterate over elements of v1 and check how many elements in v2 are same as current element in v1. Now, add those many elements to the count. This can be easily accomplished by using equal_range in C++ which returns the iterators to both lower_bound and upper_bound(simply subtracting both the iterators will give you the number of elements in v2 which are same as the current element in v1)

jranachd: 2018-01-19 20:58:02

I am getting TLE although my java solution solves all test cases in ide. Can anyone suggest something? is it allowed to post code in the comments section

vivek_prime: 2017-12-23 17:41:28

my complexity is O(n*(lgn+n)). it is coming tle. any suggestions

kmkhan_014: 2017-12-19 20:35:14

Similar to SUMFOUR!!!

amruthak: 2017-12-06 10:34:50

can any body explain problem with example

avik26091998: 2017-12-01 09:12:37

lower_bound and upper-bound !!!

trijeet: 2017-10-29 23:48:44

Beware d can't be zero ! ac in 2nd go :)

aditya930: 2017-09-23 18:50:38

Nice one..lower bound and upper bound will help O(n^3) is acceptable.

pk201996: 2017-08-25 22:00:10

nice problem use unordered_map stl

aronzx: 2017-08-22 11:20:37

Hint: Use only one unordered_map.


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