#include<cstdio>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define M 256
using namespace std;

int main(){
  int n,l[M],x,y,z;
  while(scanf("%d",&n),n){
    rep(i,n)scanf("%d",&l[i]);
    
    double m = 1e9;
    rep(s,16)rep(a,16)rep(c,16){
      int u[M] = {0};
      
      int r = s;
      rep(i,n){
	r = (a*r + c)%M;
	u[(r + l[i])%M]++;
      }
      
      double tmp = 0;
      rep(i,M)if(u[i]){
	tmp -= u[i]*log((double)u[i]/n);
	if(m + 1e-9 < tmp)break;
      }
      if(m > tmp + 1e-9){ m = tmp; x = s; y = a; z = c; }
    }
    printf("%d %d %d\n",x,y,z);
  }
}