#include<iostream>
#include<algorithm>

using namespace std;

int main(){

	int n;

	while(true){
		cin >> n;
		if(n == 0){
			break ;
		}

		int num[128];
		for(int i = 0; i < n; i++){
			cin >> num[i];
		}
	

		int want ;
		cin >> want ;

		int t,l,c,count ;
		t = 0 ;
		l = n - 1 ;

		for( count = 0; t <= l; count++){
			c = (t + l)/2 ;
			cout << t << " " << c << " " << l << endl;
			if( want > num[c] ){
				t = c + 1;
			} else if( want < num[c]){
				l = c - 1 ;
			} else {
				count++;
				break ;
			}
		}

		cout << count << endl ;
	}
	return 0;
}