#include<bits/stdc++.h>
using namespace std;
int main(){

  int N;
  
  while(1){
    cin >>N;
    if(N == 0)break;
    vector<string> vec;
    for(int i=0 ; i < N ; i++){
      string in;
      cin >>in;
      vec.push_back(in);
    }
    
    bool flag=true;
    for(int i=0 ; i < N ; i++){
      if(vec[i] != "x"){
	bool left=false,right=false;
	int temp1,temp2;
	if(i-1>=0 && vec[i-1] != "x"){
	  stringstream ss;
	  ss << vec[i-1];
	  ss >>temp1;
	  left=true;
	}
	if(i+1 < N && vec[i+1] != "x"){
	  stringstream ss2;
	  ss2 << vec[i+1];
	  ss2 >> temp2;
	  right=true;
	}
	if((i+1)%2 == 0){
	  stringstream ss3;
	  int temp3;
	  ss3 << vec[i];
	  ss3 >> temp3;
	  if(left && temp3 <= temp1){
	    flag=false;
	  }
	  if(right && temp3 <= temp2){
	    flag=false;
	  }
	}else{
	  stringstream ss4;
	  int temp4;
	  ss4 << vec[i];
	  ss4 >> temp4;
	  if(left && temp4 >= temp1){
	    flag=false;
	  }
	  if(right && temp4 >= temp2){
	    flag=false;
	  }
	}
      }
    }
    if(flag){
      int mx=1e9+100,mn=-1e9-100; 
      bool flag2 = true;
      for(int i=0 ; i < N ; i++){
	if(vec[i] == "x"){
	  if((i+1)%2 == 0){
	    if(i-1 >= 0){
	      if(vec[i-1] == "x"){
		flag2=false;
	      }else{
		stringstream ss5;
		int temp5;
		ss5 << vec[i-1];
		ss5 >> temp5;
		mn = max(mn,temp5+1);
	      }
	    }
	    if(i+1 < N){
	      if(vec[i+1] == "x"){
		flag2=false;
	      }else{
		stringstream ss6;
		int temp6;
		ss6 << vec[i+1];
		ss6 >> temp6;
		mn = max(mn,temp6+1);
	      }
	    }
	  }else{
	    if(i-1 >= 0){
	      if(vec[i-1] == "x"){
		flag2=false;
	      }else{
		stringstream ss7;
		int temp7;
		ss7 << vec[i-1];
		ss7 >> temp7;
		mx = min(mx,temp7-1);
	      }
	    }
	    if(i+1 < N){
	      if(vec[i+1] == "x"){
		flag2=false;
	      }else{
		stringstream ss8;
		int temp8;
		ss8 << vec[i+1];
		ss8 >> temp8;
		mx = min(mx,temp8-1);
	      }
	    }
	  }
	}
      }
      if(flag2){
	if(mx == mn){
	  cout <<mx<<endl;
	}else if(mx > mn){
	  cout <<"ambiguous"<<endl;
	}else{
	  cout <<"none"<<endl;
	}
      }else{
	cout <<"none"<<endl;
      }
    }else{
      cout <<"none"<<endl;
    }
  }
  
  return 0;
}