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

int N;
int X[1001];

const int INF = 2000000000;
int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      string s; cin >> s;
      if( s == "x" ) X[i] = -INF;
      else {
        stringstream sin(s);
        sin >> X[i];
      }
    }
    int r = -1000000009;
    int l =  1000000009;
    bool f = true;
    bool nf = true;
    for(int i=0;i<N;i++){
      if(i < N-1 &&  X[i] == X[i+1] && X[i] == -INF ) f = false;
      if( X[i] == -INF ){
        nf = false;
        if( i & 1 ){//even
          if( i > 0 ) r = max( X[i-1]+1,r );
          if( i < N-1 ) r = max( X[i+1]+1,r );
        } else {
          if( i > 0 ) l = min( X[i-1]-1,l );
          if( i < N-1 ) l = min( X[i+1]-1,l );
        }
      } else {
        if( i & 1 ){
          if( i > 0 && X[i-1] != -INF && X[i-1] >= X[i] ) f = false;
          if( i < N -1 && X[i+1] != -INF && X[i+1] >= X[i] ) f = false;
        } else {
          if( i > 0 && X[i-1] != -INF && X[i-1] <= X[i] ) f = false;
          if( i < N -1 && X[i+1] != -INF && X[i+1] <= X[i] ) f = false;
        }
      }
      //cout << X[i] << " " << l <<" "<< r << endl;
    }
    //  cout << f<< " "<< nf << " " << l << " " << r << endl;
    if( !f ) cout << "none" << endl;
    else if( nf ) cout << "ambiguous" << endl;
    else if( l == r ) cout << l << endl;
    else if( l < r ) cout << "none" << endl;
    else cout << "ambiguous" << endl;
  }
}