#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9 + 2;

int stoii(string s){
    int res = 0;
    bool m = 0;
    REP(i,s.length()){
        if (s[i] == '-') m = 1;
        else res = 10*res + s[i]-'0';
    }
    if (m) res *= -1;
    return res;
}

int main() {
    int n;
    while (cin >> n && n){
        VI a(n+2), c(n+2);
        FOR(i,1,n){
            string s;
            cin >> s;
            if (s == "x") {
                c[i] = 1;
                if (i % 2 == 1)
                    a[i] = -INF;
                else
                    a[i] = INF;
            }
            else a[i] = stoii(s);
        }
        a[0] = INF;
        if (n % 2 == 1) a[n+1] = INF;
        else a[n+1] = -INF;
        bool d = 0;
        FOR(i,1,n-1) if (c[i] & c[i+1]) d = 1;
        FOR(i,1,n){
            if (i % 2 == 1 && (a[i] >= a[i-1] || a[i] >= a[i+1])) d = 1;
            if (i % 2 == 0 && (a[i] <= a[i-1] || a[i] <= a[i+1])) d = 1;
        }
        if (d) {
            cout << "none" << endl;
            continue;
        }

        int mi = -INF, ma = INF;
        FOR(i,1,n){
            if (c[i] && i % 2 == 1)
                ma = min({ma, a[i-1]-1, a[i+1]-1});
            else if (c[i] && i % 2 == 0)
                mi = max({mi, a[i-1]+1, a[i+1]+1});
        }

        if (mi == ma) cout << mi << endl;
        else if (mi < ma) cout << "ambiguous" << endl;
        else cout << "none" << endl;
    }
    return 0;
}