#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#define pi acos(-1.0)
using namespace std;
typedef long long ll;
struct cp
{
double x,y;
cp (double a,double b){x=a,y=b;}
cp (){}
cp operator + (cp a){return cp(x+a.x,y+a.y);}
cp operator - (cp a){return cp(x-a.x,y-a.y);}
cp operator * (cp a){return cp(x*a.x-y*a.y,x*a.y+y*a.x);}
cp operator * (double a){return cp(x*a,y*a);}
}n1[1<<19],n2[1<<19],n3[1<<19];
int n,m,top,len;
int ans[1<<19];
ll s[1<<19];
void FFT(cp *a,int f)
{
int i,j,k,h;
cp t;
for(i=k=0;i<len;i++)
{
if(i>k) swap(a[i],a[k]);
for(j=(len>>1);(k^=j)<j;j>>=1);
}
for(h=2;h<=len;h<<=1)
{
cp wn(cos(f*2*pi/h),sin(f*2*pi/h));
for(j=0;j<len;j+=h)
{
cp w(1,0);
for(k=j;k<j+h/2;k++) t=w*a[k+h/2],a[k+h/2]=a[k]-t,a[k]=a[k]+t,w=w*wn;
}
}
}
int rd()
{
int ret=0,f=1; char gc=getchar();
while(gc<‘0‘||gc>‘9‘) {if(gc==‘-‘)f=-f; gc=getchar();}
while(gc>=‘0‘&&gc<=‘9‘) ret=ret*10+gc-‘0‘,gc=getchar();
return ret*f;
}
int main()
{
n=rd();
int i,a;
for(i=1;i<=n;i++) a=rd(),n1[a].x+=1,s[a]++,n2[a<<1].x+=1,n3[a*3].x+=1,m=max(m,a);
for(len=1;len<=m*3;len<<=1);
FFT(n1,1),FFT(n2,1),FFT(n3,1);
for(i=0;i<len;i++)
{
cp x=n1[i],y=n2[i],z=n3[i];
n2[i]=((x*x)-y)*(1.0/2),n3[i]=((x*x*x)-(x*y*3.0)+(z*2.0))*(1.0/6);
}
FFT(n2,-1),FFT(n3,-1);
for(i=0;i<len;i++) s[i]+=(ll)(n2[i].x/len+0.1)+(ll)(n3[i].x/len+0.1);
for(i=0;i<len;i++) if(s[i]) ans[++top]=i;
for(i=1;i<=top;i++) printf("%d %lld\n",ans[i],s[ans[i]]);
return 0;
}