#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#include <cmath>
#define INF 10000000000
#define MOD 10000000007
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> i_i;

int main(){
    for (; ;) {
        int n;
        cin >> n;
        //cout << n <<endl;
        if(!n) break;
        /*for (int i=0; i<n; i++) {
            string s;
            cin >> s;
            if(i!=0) cout <<" ";
            cout <<s;
        }
        cout << endl;
        */
        vector<ll> data(n);
        for (int i=0; i<n; i++) {
            string s;
            cin >> s;
            if (s=="x") {
                data[i]=MOD;
            }else{
                ll inp=0;
                for (int i = s.length()-1; i>=0;i--) {
                    if(s[i]=='-'){
                        inp *= -1;
                        continue;
                    }
                    inp += ((int)s[i]-(int)'0')*pow(10, s.length()-1-i);
                }
                data[i]=inp;
            }
        }
        bool ch = true, hoge=true;
        ll ub=-INF, ob=INF;
        for (int i=0; i<n; i++) {
            if(data[i]==MOD){
                if(i%2==1){
                    ll a = -INF,b =-INF;
                    if(i>0){
                        if(data[i-1]==MOD){ hoge=false;
                        }else{
                            a = data[i-1];
                        }
                    }
                    if(i<n-1){
                        if(data[i+1]==MOD){ hoge=false;
                        }else{
                            b = data[i+1];
                        }
                    }
                    ub = max(ub,max(a, b));
                }
                if(i%2==0){
                    ll a = INF,b =INF;
                    if(i>0){
                        if(data[i-1]==MOD){ hoge=false;
                        }else{
                            a = data[i-1];
                        }
                    }
                    if(i<n-1){
                        if(data[i+1]==MOD){ hoge=false;
                        }else{
                            b = data[i+1];
                        }
                    }
                    ob = min(ob,min(a, b));
                }
            }else{
                if (i==0) {
                    if (i+1<n and data[i+1]!=MOD) {
                        if (data[0]>=data[1]) {
                            ch = false;
                        }
                    }
                    continue;
                }
                if(i%2==1){
                    if (i >0 and data[i]<=data[i-1] and data[i-1]!=MOD) {
                        ch = false;
                    }
                    
                }else{
                    if (i>0 and data[i]>=data[i-1] and data[i-1]!=MOD) {
                        ch = false;
                    }
                }
            }
        }
        ob--;
        ub++;
        if (ob==9999999999 and ub !=-9999999999) {
            ub = ob-100;
        }
        if (ob!=9999999999 and ub ==-9999999999) {
            ob = ub+100;
        }
        //cout << ob <<"  "<<ub <<endl;
    
        if (ob == ub and ch and hoge) {
            cout << ob << endl;
        }else{
            if (ob>ub and ch and hoge) {
                cout << "ambiguous"<<endl;
            }else{
                cout << "none"<<endl;
            }
        }
    }
}

Measured memory_bytes: 1256