#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

const int m=256;
const int INF=1000000000;
int val[300];
int calc(int idx,int a,int c){
    if(val[idx]!=INF)
        return val[idx];
    int res=(a*calc(idx-1,a,c)+c)%m;
    return val[idx]=res;
}

int main(){

    int n;
    while(cin>>n&&n!=0){
        int ap[256];
        int l[300];
        double minTropy=INF;
        int aa,cc,ss;
        for(int i = 0; i < n; i++)
            cin>>l[i];
        for(int s = 0; s <= 15; s++){
            for(int a = 0; a <= 15; a++){
                for(int c = 0; c <= 15; c++){
                    fill(val,val+300,INF);
                    fill(ap,ap+256,0);
                    val[0]=s;
                    if(a==7&&c==9){
        //               cout<<endl;
                    }
                    for(int i = 1; i <= n; i++){
                        ap[(l[i-1]+calc(i,a,c))%m]++;
                    }
                    double sum=0;
                    for(int i = 0; i < 256; i++){
                        if(ap[i]!=0){
                            sum-=(1.0*ap[i]/n)*(log((double)ap[i])/n);
                        }
                    }
                    if(!EQ(sum,minTropy)&&sum<minTropy){
                        minTropy=sum;
                        ss=s;aa=a;cc=c;
                    }
                }
            }
        }
        cout<<ss<<" "<<aa<<" "<<cc<<endl;
    }

    return 0;
}