#include<iostream>
#include<algorithm>
#include<sstream>
using namespace std;
typedef long long ll;

const ll INF = 2*1e9;

ll StoLL(string s){
  if(s=="x")return INF+1;
  stringstream ss(s);
  ll res;
  ss >> res;
  return res;
}

int main(){
  ll n,a[1010];
  string s;

  while(cin >> n, n){
    bool f = 0;
    for(int i=0;i<n;i++)cin >> s, a[i] = StoLL(s);
    
    for(int i=1;i<n;i++){
      if(a[i] == a[i-1])f = 1;
      if(a[i]>INF || a[i-1]>INF)continue;
      if((i&1)==1 && a[i] < a[i-1])f = 1;
      if((i&1)==0 && a[i] > a[i-1])f = 1;
    }
    
    if(f){
      cout << "none" << endl;
      continue;
    }
    
    ll l = -INF, r = INF;
    for(int i=0;i<n;i++){
      if(a[i]>INF){
	if(i&1){
	  if(i)l=max(l,a[i-1]+1);
	  if(i+1<n)l=max(l,a[i+1]+1);
	}else{	  
	  if(i)r=min(r,a[i-1]-1);
	  if(i+1<n)r=min(r,a[i+1]-1);
	}
      }
    }
    
    if(l>r)cout << "none" << endl;
    else if(r-l>0)cout << "ambiguous" << endl;
    else cout << l << endl;
  }
}