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
karthik1997: 2016-09-28 18:47:35

Even though unordered_map uses O(n^3) and bounds uses O(n^3logn) ,, map tle's while upper and lower bound got ac

hamjosh1: 2016-09-10 13:41:09

My 15th :P . Tricky one case when D==0

Shivam: 2016-09-07 10:10:50

HashMap<Integer , Integer> times out. Any ideas why ?

Mihir Saxena: 2016-09-04 13:17:38

Kept on getting a TLE repeatedly on using MAP structure, just replaced the map keyword by unordered_map all over the program, rest of the code was the same and got accepted :)

manish3749: 2016-08-19 17:33:01

accepted in 2nd go
--> 2 vectors for lhs nd rhs
--> 1 sort function for rhs vector
--> lower and upper for lhs in rhs
--> cout<<ub-v2.begin())-(lb-v2.begin();

chaturvedi: 2016-08-06 21:59:05

how is it happening can't understand plz help

sieunhanbom04: 2016-08-04 07:12:21

Map will make you get TLE. Use lower_bound and upper_bound guys. O(n^3.logn). GL

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

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