P,i,I[999],c[999],n,r;double h,H;main(p){for(;i=scanf("%d",&n)*n;printf("%d %d %d\n",p>>8,p>>4&15,p&15)){for(h=9e9;i;)scanf("%d",I+--i);for(P=4096;P--;memset(c,H=0,2e3)){for(r=P>>8,i=n;i;++c[I[--i]+r&255])r=P/16%16*r+P%16&255;for(i=256;i--;H-=c[i]*log(fmax(c[i],1)/n));h>H-1e-9?h=H,p=P:0;}}}