TSUM - Triple Sums

题意翻译

N个整数$A_1,A_2,\dots,A_N$,对所有的$S$,求满足$A_i+A_j+A_k = S $且$i < j < k$的$(i,j,k)$对数. $N \le 40000, A_i \le 20000$ 感谢@The_Unbeatable 提供的翻译

题目描述

You're given a sequence **s** of **N** distinct integers. Consider all the possible sums of three integers from the sequence at three different indicies. For each obtainable sum output the number of different triples of indicies that generate it. **Constraints:** N <= 40000, |s $ _{i} $ | <= 20000

输入输出格式

输入格式


The first line of input contains a single integer N. Each of the next N lines contain an element of s.

输出格式


Print the solution for each possible sum in the following format: sum\_value : number\_of\_triples Smaller sum values should be printed first.

输入输出样例

输入样例 #1

5
-1
2
3
0
5

输出样例 #1


1 : 1
2 : 1
4 : 2
5 : 1
6 : 1
7 : 2
8 : 1
10 : 1