#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

const int VAR = (1 << 31);
int n;
signed main() {
    while(cin >> n, n) {
        vector<int> a(n);
        rep(i,0,n) {
            string c; cin >> c;
            if(c == "x") a[i] = VAR;
            else a[i] = atoi(c.c_str());
        }

        bool ok = true;
        int mi = -INF, ma = INF;
        rep(i,0,n) {
            if(a[i] == VAR) {
                if(i != 0) {
                    if(a[i-1] == VAR) ok = false;
                    else if(i % 2) mi = max(mi, a[i-1] + 1);
                    else ma = min(ma, a[i-1] - 1);
                }
                if(i != n-1) {
                    if(a[i+1] == VAR) ok = false;
                    else if(i % 2) mi = max(mi, a[i+1] + 1);
                    else ma = min(ma, a[i+1] - 1);
                }
            }
            else {
                if(i != 0) {
                    if(i % 2 && a[i-1] != VAR && a[i-1] > a[i]) ok = false;
                    if(!(i%2)&& a[i-1] != VAR && a[i-1] < a[i]) ok = false;
                }
                if(i != n-1) {
                    if(i % 2 && a[i+1] != VAR && a[i+1] > a[i]) ok = false;
                    if(!(i%2)&& a[i+1] != VAR && a[i+1] < a[i]) ok = false;
                }
            }
        }
        if(!ok) cout << "none" << endl;
        else {
            // printf("mi = %lld, ma = %lld\n", mi, ma);
            if(mi > ma) cout << "none" << endl;
            else if(mi == ma) cout << mi << endl;
            else cout << "ambiguous" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3004