#include<iostream>
#include<cmath>

using namespace std;

struct S{
	double min;
	int s, a, c;
};

int main(){

	int N, l[257],r[257],o[257],x[257];
	int s, a, c;
	double H;
	S ans;

	while (1){

		cin >> N;
		if (N == 0) break;

		for (int i = 1; i <= N; i++){
			cin >> l[i];
		}

		for (s = 0; s <= 15; s++){
			for (a = 0; a <= 15; a++){
				for (c = 0; c <= 15; c++){
					r[0] = s;
					for (int i = 1; i <= N; i++){
						r[i] = (a*r[i - 1] + c) % 256;
					}
					for (int i = 1; i <= N; i++){
						o[i] = (l[i] + r[i]) % 256;
					}
					for (int i = 0; i < 256; i++) {
						x[i] = 0;
					}
					for (int i = 1; i <= N; i++){
						x[o[i]]++;
					}
					H = 0;
					for (int i = 0; i < 256; i++){
						if(x[i]!=0) H += ((double)x[i] / N)*log((double)x[i] / N);
					}
					H *= -1;
					if (s == 0 && a == 0 && c == 0 || ans.min>H+1e-9){
						ans.min = H;
						ans.s = s, ans.a = a, ans.c = c;
					}
				}
			}
		}
		cout << ans.s << " " << ans.a << " " << ans.c << endl;
	}
	return 0;
}