#include <bits/stdc++.h>
using namespace std;
int INF = 10000;
int main(){
  while (1){
    int N;
    cin >> N;
    if (N == 0){
      break;
    }
    vector<int> l(N);
    for (int i = 0; i < N; i++){
      cin >> l[i];
    }
    double m = INF;
    int s, a, c;
    for (int S = 0; S < 16; S++){
      for (int A = 0; A < 16; A++){
        for (int C = 0; C < 16; C++){
          vector<int> R(N + 1);
          R[0] = S;
          for (int i = 0; i < N; i++){
            R[i + 1] = (R[i] * A + C) % 256;
          }
          vector<int> O(N);
          for (int i = 0; i < N; i++){
            O[i] = (l[i] + R[i + 1]) % 256;
          }
          vector<int> cnt(256, 0);
          for (int i = 0; i < N; i++){
            cnt[O[i]]++;
          }
          double tmp = 0;
          for (int i = 0; i < 256; i++){
            if (cnt[i] > 0){
              double r = (double) cnt[i] / N;
              tmp -= r * log(r);
            }
          }
          if (tmp < m - 0.001){
            m = tmp;
            s = S;
            a = A;
            c = C;
          }
        }
      }
    }
    cout << s << ' ' << a << ' ' << c << endl;
  }
}
