#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
using namespace std;
typedef tuple<int,int,int> T;
const int M = 256;

int main(){
    int N;
    while(cin>>N,N){
        vector<int> I(N);
        for(auto &i:I)cin>>i;
        double entropy = 1e20;
        int occur[M];
        T ans;
        for(int S=0;S<16;S++){
            for(int A=0;A<16;A++){
                for(int C=0;C<16;C++){
                    int R = S;
                    fill(occur,occur+M,0);
                    for(auto i:I){
                        R=(A*R+C)%M;
                        occur[(R+i)%M]++;
                    }
                    double H = 0;
                    sort(occur,occur+M);
                    for(int i=0;i<M;i++){
                        if(occur[i])H-=double(occur[i])/N*log(double(occur[i])/N);
                    }
                    if(entropy>H){
                        entropy=H;
                        ans=T(S,A,C);
                    }
                }
            }
        }
        int S,A,C;
        tie(S,A,C)=ans;
        cout<<S<<' '<<A<<' '<<C<<endl;
    }
    return 0;
}