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:
20160928 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:
20160910 13:41:09
My 15th :P . Tricky one case when D==0 

Shivam:
20160907 10:10:50
HashMap<Integer , Integer> times out. Any ideas why ? 

Mihir Saxena:
20160904 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:
20160819 17:33:01
accepted in 2nd go


chaturvedi:
20160806 21:59:05
how is it happening can't understand plz help 

sieunhanbom04:
20160804 07:12:21
Map will make you get TLE. Use lower_bound and upper_bound guys. O(n^3.logn). GL 

sravanthreddy:
20160803 19:51:45
careful about d!=0 :)


nurlansofiyev:
20160724 10:39:54
same algorithm AC with stl::unordered_map, and TLE with stl:map. and there is solution without any stl container


sonali9696:
20160718 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: 20160718 14:02:36 
Added by:  Luka Kalinovcic 
Date:  20090713 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO NODEJS PERL6 VB.NET 
Resource:  own problem 