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



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

hide comments
2013-10-20 18:07:59 (Tjandra Satria Gunawan)(曾毅昆)
C->stdlib.h->qsort() is very slow :-(
AC using manual sort..
2013-09-23 17:14:38 Ouditchya Sinha
@santhosh reddy : I'm not sure but I didn't assume the input to be sorted.
2013-09-23 14:16:39 santhosh reddy
Is the input always sorted???
2013-09-14 19:27:49 Vinay Kumar
getting TLE any suggestions. <snip>

Last edit: 2023-06-14 21:15:26
2013-07-25 02:28:29 Anmol Singh Jaggi
Use STL sort() instead of stable_sort()!!
Got many TLE's for that...
2013-06-05 18:32:43 Inspiron
O(n^3log(n)). n^3log(n),arround 10^7 and its mangble withine a second for a normal computer(PC)

Last edit: 2013-08-01 14:11:23
2013-04-26 12:19:48 Ouditchya Sinha
Got AC with pretty bad run times, upper_bound & lower_bound works well here. Strange, I got a poor timing of 11.17s with getchar_unlocked & 10.28s with scanf... My time complexity is O( n^3 + n * log(n) ). :)

EDIT: My mistake, getchar_unlocked did give me 10.22s.

Last edit: 2013-04-26 12:41:04
2013-04-11 21:23:24 Shawkey
is the best solution O(n^3 log(n)) or O(n^3 log(n^3))???
2013-03-16 07:03:02 Jay H. Bosamiya
O(n^3 lg n) is giving TLE... I'm using STL map... is STL map slow?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.