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
sravanthreddy: 2016-08-03 19:51:45

careful about d!=0 :)

nurlansofiyev: 2016-07-24 10:39:54

same algorithm AC with stl::unordered_map, and TLE with stl:map. and there is solution without any stl container

sonali9696: 2016-07-18 13:53:59

Umm I didn't even use binary search, i got AC. ab + c = d(e+f). Store all possible combinations of lhs & rhs in array and see frequency of occurrences of an element linearly. Didn't even use upper_bound, lower_bound or anything. O(N^3 log n) --> because of sorting

Last edit: 2016-07-18 14:02:36
p_kr: 2016-07-18 07:13:58

AC after 6 TLEs
-- used unordered_map, int instead of long long and two n^3 loops

baadshah_: 2016-07-15 18:57:50

Finally Got AC after Soooo many TLE
-->used long long only to store final ans
-->used STL sort() and vector
-->used lower_bound() and upper_bound()
-->used scanf()

Shubham Gupta: 2016-07-06 22:39:53

"d ! = 0" :)

kiwi1995: 2016-07-04 12:25:35

TLE :'(

mkfeuhrer: 2016-07-02 13:43:37

sort then lower bound then upper bound !! AC in 1 go :-)

hash7: 2016-07-02 07:44:27

fallen in love with binary search :D ...similar to sumfour

cat_got_bored: 2016-06-30 15:45:45

I hate SPOJ problems for these reasons , It's not about the algorithm I choose ,It's about how someone codes it, This is a easy problem but still getting nonsense TLE s. Waste of time!


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