#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){break;}
		
		int mini=-1e9-10,maxi=1e9+10;
		int a[1100] = {};
		for(int i = 0;i < n;i++){
			string s;
			cin >> s;
			if(s[0] == 'x'){
				a[i] = 1e9 + 2;
			}else{
				int num;
				sscanf(s.c_str(),"%d",&num);
				a[i] = num;
			}
		}
		
		bool flag = true;
		for(int i = 1;i<n;i++){
			if((i+1) % 2 == 0){
				if(a[i] == 1e9+2){
					if(a[i-1] == 1e9+2){
						flag = false;
						break;
					}else{
						mini = max(mini,a[i-1]+1);
					}
				}else{
					if(a[i-1] == 1e9+2){
						maxi = min(maxi,a[i]-1);
					}else{
						if(a[i] < a[i-1]){
							flag = false;
							break;
						}
					}
				}
			}else{
				if(a[i] == 1e9+2){
					if(a[i-1] == 1e9+2){
						flag = false;
						break;
					}else{
						maxi = min(maxi,a[i-1]-1);
					}
				}else{
					if(a[i-1] == 1e9+2){
						mini = max(mini,a[i]+1);
					}else{
						if(a[i] > a[i-1]){
							flag = false;
							break;
						}
					}
				}
			}
		}
		
		//cout << maxi << " " << mini << endl;
		if(flag){
			if(maxi == mini){
				cout << maxi << endl;
			}else{
				if(maxi < mini){
					cout << "none" << endl;
				}else{
					cout << "ambiguous" << endl;
				}
			}
		}else{
			cout << "none" << endl;
		}
	}
	return 0;
}
