#include <bits/stdc++.h>
using namespace std;

const int MAX=256;
const double EPS=1e-6;

int N,S,A,C,R; double M,e,t;
vector<int> I(MAX);
map<int,int> cnt;

void solve(){
    M=1e9;
    for (int s=0;s<=15;++s){
        for (int a=0;a<=15;++a){
            for (int c=0;c<=15;++c){
                R=s; e=0;
                cnt.clear();
                for (int i=0;i<N;++i){
                    R=(a*R+c)%MAX;
                    ++cnt[(I[i]+R)%MAX];
                }
                for (auto p:cnt){
                    t=(double)p.second;
                    e-=t/(double)N*log(t/(double)N);
                }
                if (e+EPS<M){
                    M=e;
                    S=s,A=a,C=c;
                }
            }
        }
    }
    cout << S << ' ' << A << ' ' << C << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N,N){
        for (int i=0;i<N;++i) cin >> I[i];
        solve();
    }
}
