#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;


int main(){
    int n, search;
    while (cin >> n && n){
	int inp[101];
	for (int i = 0; i < n; i++) cin >> inp[i];
	cin >> search;

	int *s = inp, *e = inp + n - 1, *p = inp + (n-1)/2;
	int ans = 0;
	int b = 0;
	while (1){
	    ans++;
	    cout << *s << " " << *p << " " << *e << endl;
	    if (p == s && p == e) break;
	    if (*p == search) break;
	    else if (*p > search){
		e = p-1;
		p = s + (e - s)/2;
	    }
	    else if (*p < search){
		s = p+1;
		p = s + (e - s)/2;
	    }
	}

	cout << ans << endl;
    }
}