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

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int a[1252];
bool broken[1252];
char buf[1252];

int main(){
	while(true){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		REP(i,n){
			scanf("%s",buf);
			if(buf[0]=='x'){
				broken[i] = true;
			}else{
				broken[i] = false;
				a[i] = atoi(buf);
			}
			int len = strlen(buf);
			fill(buf,buf+len,'\0');
		}
		int ub = 1<<30, lb = -(1<<30);
		REP(i,n)if(broken[i]){
			if(i%2==0){
				// ub
				if(i+1<n && !broken[i+1])ub = min(ub,a[i+1]-1);
				if(i-1>=0&& !broken[i-1])ub = min(ub,a[i-1]-1);
			}else{
				if(i+1<n && !broken[i+1])lb = max(lb,a[i+1]+1);
				if(i-1>=0&& !broken[i-1])lb = max(lb,a[i-1]+1);
			}
		}
		bool ng = false;
		REP(i,n)if(!broken[i]){
			if(i%2==0){
				// smaller
				if(i+1<n && !broken[i+1] && !(a[i]<a[i+1]))ng=true;
				if(i-1>=0&& !broken[i-1] && !(a[i]<a[i-1]))ng=true;
			}else{
				if(i+1<n && !broken[i+1] && !(a[i]>a[i+1]))ng=true;
				if(i-1>=0&& !broken[i-1] && !(a[i]>a[i-1]))ng=true;
			}
		}
		REP(i,n-1)if(broken[i] && broken[i+1])ng = true;
		if(ub<lb || ng)puts("none");
		else if(ub==lb)printf("%d\n",ub);
		else puts("ambiguous");
	}
}
