1 #include<cstdio>
2 #include<cstdlib>
3 #include<cstring>
4 #include<iostream>
5 #include<algorithm>
6 #include<cmath>
7 using namespace std;
8 #define Maxn 800010
9 const double eps=0.000001;
10 const double pi=acos(-1);
11
12 struct P
13 {
14 double x,y;
15 P() {x=y=0;}
16 P(double x,double y):x(x),y(y){}
17 friend P operator + (P x,P y) {return P(x.x+y.x,x.y+y.y);}
18 friend P operator - (P x,P y) {return P(x.x-y.x,x.y-y.y);}
19 friend P operator * (P x,P y) {return P(x.x*y.x-x.y*y.y,x.x*y.y+x.y*y.x);}
20 friend P operator * (P x,int y) {return P(x.x*y,x.y*y);}
21 friend P operator / (P x,int y) {return P(x.x/y,x.y/y);}
22 }a[Maxn],b[Maxn],c[Maxn];
23
24 int R[Maxn],nn;
25 void fft(P *s,int f)
26 {
27 for(int i=0;i<nn;i++) if(i<R[i]) swap(s[i],s[R[i]]);
28 for(int i=1;i<nn;i<<=1)
29 {
30 P wn(cos(pi/i),f*sin(pi/i));
31 for(int j=0;j<nn;j+=i<<1)
32 {
33 P w(1,0);
34 for(int k=0;k<i;k++,w=w*wn)
35 {
36 P x=s[j+k],y=w*s[j+k+i];
37 s[j+k]=x+y;s[j+k+i]=x-y;
38 }
39 }
40 }
41 if(f==-1)
42 {
43 for(int i=0;i<=nn;i++)
44 {
45 s[i]=s[i]/nn;
46 }
47 }
48 }
49
50 int main()
51 {
52 int n,mx=0;
53 scanf("%d",&n);n--;
54 for(int i=0;i<=n;i++)
55 {
56 int x;
57 scanf("%d",&x);
58 a[x].x=1;
59 b[2*x].x=1;
60 c[3*x].x=1;
61 mx=max(mx,x);
62 }
63 nn=1;int ll=0;
64 while(nn<=3*mx) nn<<=1,ll++;
65 for(int i=0;i<=nn;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(ll-1));
66 fft(a,1);
67 fft(b,1);fft(c,1);
68 for(int i=0;i<=nn;i++)
69 {
70 a[i]=a[i]+(a[i]*a[i]-b[i])/2+(a[i]*a[i]*a[i]-a[i]*b[i]*3+c[i])/6;
71 }
72 fft(a,-1);
73 for(int i=0;i<=nn;i++)
74 {
75 if(int(a[i].x+0.5)){
76 printf("%d %d\n",i,int(a[i].x+0.5));
77 }
78 }
79 return 0;
80 }