#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,n) for(int i=(int)(n-1);i>=0;--i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1000000000

int main() {
    int N;
    while (cin >> N, N) {
        vi in(N);
        REP(i, N) cin >> in[i];

        double ans = INF;
        tuple<int, int, int> res = make_tuple(INF, INF, INF);
        RREP(S, 16) RREP(A, 16) RREP(C, 16) {
            vi out(N);
            map<int, int> occurences;
            int R = S;
            REP(i, N) {
                R = (A * R + C) % 256;
                out[i] = (in[i] + R) % 256;
                occurences[out[i]]++;
            }
            double H = 0;
            for (auto kv : occurences) {
                double r = kv.second / double(N);
                H += r * (log(r) / log(2));
            }
            if (ans >= -H) {
                ans = -H;
                res = min(res, make_tuple(S, A, C));
            }
        }
        printf("%d %d %d\n", get<0>(res), get<1>(res), get<2>(res));
    }
}