#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        rep(i,n)cin>>s[i];
        int mi=-inf;
        int ma=inf;
        rep(i,n){
            if(s[i]=="x"){
                if(i>0&&s[i-1]=="x"||i<n-1&&s[i+1]=="x"){
                    cout<<"none"<<endl;
                    goto LOOP;
                }
                if(i%2==0){
                    if(i>0)ma=min(ma,stoll(s[i-1])-1);
                    if(i<n-1)ma=min(ma,stoll(s[i+1])-1);
                }
                else{
                    mi=max(mi,stoll(s[i-1])+1);
                    if(i<n-1)mi=max(mi,stoll(s[i+1])+1);
                }
            }
            else if(i%2&&(s[i-1]!="x"&&stoi(s[i-1])>stoi(s[i])||i<n-1&&s[i+1]!="x"&&stoi(s[i+1])>stoi(s[i]))){
                cout<<"none"<<endl;
                goto LOOP;
            }
            else if(i%2==0&&(i>0&&s[i-1]!="x"&&stoi(s[i-1])<stoi(s[i])||i<n-1&&s[i+1]!="x"&&stoi(s[i+1])<stoi(s[i]))){
                cout<<"none"<<endl;
                goto LOOP;
            }
            // cout<<mi<<" "<<ma<<endl;
        }
        if(ma==mi)cout<<ma<<endl;
        else if(ma<mi)cout<<"none"<<endl;
        else cout<<"ambiguous"<<endl;
        LOOP:;
    }
}
