#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int buckets[256];
int main(int argc,char const* argv[])
{
  while(1)
    {
      int n,trues,truea,truec;
      int m=256;
      cin >> n;
      if(!n)break;
      vi l(n+5);
      vi r(n+5);
      vi o(n+5);
      for(int i=1;i<=n;i++)
	{
	  cin >> l[i];
	}
      double ans=1000;
      for(int s=0;s<=15;s++)
	{
	  for(int a=0;a<=15;a++)
	    {
	      for(int c=0;c<=15;c++)
		{
		  memset(buckets,0,sizeof(buckets));
		  for(int i=0;i<=n;i++)
		    {
		      if(i==0) r[i]=s;
		      else
			{
			  r[i]=(a*r[i-1]+c)%m;
			  o[i]=(l[i]+r[i])%m;
			  buckets[o[i]]++;
			}
		    }
		  double tmp=0;
		  for(int i=0;i<=255;i++)
		    {
		      if(buckets[i]!=0)
			{
			  tmp-=buckets[i]/(double)n*log(buckets[i]/(double)n);
			}
		    }
		  if(tmp+eps<ans)
		    {
		      ans=tmp;
		      trues=s;
		      truea=a;
		      truec=c;
		    }
		}
	    }
	}
      cout << trues << ' ' << truea << ' ' << truec << endl;
    }
  return 0;
}

