#include <bits/stdc++.h>
using namespace std;

void solve(int n){
	int a[n];
	vector<string> v;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		if(s == "x") a[i] = 1e9+7;
		else a[i] = stoi(s);
	}
	int l = -1e9-7;
	int r = 1e9+7;
	for(int i=0; i<n-1; ++i){
		if((a[i] == 1e9+7 && a[i+1] == 1e9+7)){
			cout << "none\n";
			return;
		}else if(a[i] == 1e9+7){
			if(i % 2 == 0){
				r = min(r, a[i+1]-1);
			}else{
				l = max(l, a[i+1]+1);
			}
		}else if(a[i+1] == 1e9+7){
			if(i % 2 == 0){
				l = max(l, a[i]+1);
			}else{
				r = min(r, a[i]-1);
			}
		}else{
			if(a[i] == a[i+1] || (i % 2 == 0 && a[i] > a[i+1]) || (i % 2 == 1 && a[i] < a[i+1])){
				cout << "none\n";
				return;
			}
		}
	}
	if(l == r) cout << l << "\n";
	else if(l < r) cout << "ambiguous\n";
	else cout << "none\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}
