#include <cstdio>
#include <algorithm>

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

using namespace std;

const int INF=1000000010;
const int X=INF;

int main(){
	for(int n;scanf("%d",&n),n;){
		int a[1000];
		rep(i,n){
			char s[32]; scanf("%s",s);
			if(s[0]=='x') a[i]=X;
			else sscanf(s,"%d",a+i);
		}

		bool cont=false;
		rep(i,n-1) if(a[i]==X && a[i+1]==X) cont=true;
		if(cont){ puts("none"); continue; }

		int l=-INF,r=INF;
		bool bad=false;
		rep(i,n){
			if(a[i]==X){
				if(i%2==0){
					if(0<=i-1 && i-1<n) r=min(r,a[i-1]-1);
					if(0<=i+1 && i+1<n) r=min(r,a[i+1]-1);
				}
				else{
					if(0<=i-1 && i-1<n) l=max(l,a[i-1]+1);
					if(0<=i+1 && i+1<n) l=max(l,a[i+1]+1);
				}
			}
			else{
				if(i%2==0){
					if(0<=i-1 && i-1<n && a[i-1]!=X && a[i-1]<=a[i]) bad=true;
					if(0<=i+1 && i+1<n && a[i+1]!=X && a[i+1]<=a[i]) bad=true;
				}
				else{
					if(0<=i-1 && i-1<n && a[i-1]!=X && a[i-1]>=a[i]) bad=true;
					if(0<=i+1 && i+1<n && a[i+1]!=X && a[i+1]>=a[i]) bad=true;
				}
			}
		}

		if(bad || l>r) puts("none");
		else if(l<r) puts("ambiguous");
		else printf("%d\n",l);
	}

	return 0;
}