#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int n, m;
double calc(vector<int> &cnt){
	double res = 0;
	for (double x : cnt){
		if(x) res -= x / n*log(x / n);
	}
	return res;
}

tuple<int, int, int> bf(vector<int> &v){
	pair<double, tuple<int, int, int>> ans;
	ans = MP(1e9, MT(-1, -1, -1));
	rep(s, 16) rep(a, 16) rep(c, 16){
		vector<int> cnt(256);
		int r = s;
		rep(i, v.size()){
			r = (a*r + c) % m;
			++cnt[(v[i] + r) % m];
		}
		ans = min(ans, MP(calc(cnt), MT(s, a, c)));
		ans.first -= 1e-9;
	}
	return ans.second;
}

int main(){
	m = 256;
	while (cin >> n, n){
		vector<int> v(n);
		rep(i, n) cin >> v[i];
		int s, a, c;
		tie(s, a, c) = bf(v);
		cout << s << ' ' << a << ' ' << c << '\n';
	}

	return 0;
}