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
Pragya Mishra: 2014-01-13 15:19:42

used qsort() and it resulted in TLE...

silence_dogood: 2014-01-11 12:45:33

getting WA after the 11th case.. can anyone help? :/ here is my code. http://ideone.com/tXq8M7

Laxus!!: 2013-12-22 17:59:36

50th One!!!!...Needed Little Optimisation!!

Mostafa 36a2: 2013-12-15 21:41:40

try asking in the forum :)

Ishan Bhatt: 2013-12-15 12:08:24

Still can't figure out the problem! Tried comparing results against the Brute Force ones for over 50 random inputs - all successes. Getting WA after 11th test file. Help anyone!

Last edit: 2013-12-15 20:32:53
Mostafa 36a2: 2013-12-12 23:51:03

@Ishan Bhatt : solve the problem for more than 10 hard test cases,using pen and paper or Brute force , then compare the results with your enhanced algorithm .. and you'll find the bug.
test for some special values like 0,1,-1
make sure that u really understand the problem , and after ~100 failure u can ask for help
best wishes :)

Ishan Bhatt: 2013-12-12 21:05:50

Getting WA after 11th test case. Can the admin please have a look? Code is well commented for convenience. Solution id: 10648244. Please comment if you find where I went wrong, otherwise my email id is included in the source code.

Last edit: 2013-12-12 21:06:29
Himanshu Dagar: 2013-11-26 20:42:41

Really nice one
!!!

Martijn Muijsers: 2013-11-26 15:44:35

Passed with O(n^3log(n)). Awesome problem! Hint: make sure you don't count sextuples where d=0 (when you've got a solution of course haha, good luck!) (Also, I made breakfast while waiting for test cases to complete XD)

Last edit: 2013-11-27 00:47:32
Sourav Chatterjee: 2013-10-29 05:25:42

AC Finally. Wasted a whole day on this, but learnt a lot.
Time limit is very tight on this. Don't use vectors, use arrays. Also, be careful. sort is n^3 log n^3 and binary search n^3 times is also n^3 log n^3, but the constants actually matter. And the binary search does not work as fast for me.


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