#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    while (cin >> N, N)
    {
        vector<ll> a(N + 1);
        int cnt = 0;
        bool cons = false;
        for (int i = 1; i <= N; i++)
        {
            string s;
            cin >> s;
            if (s == "x")
            {
                cnt++;
                a[i] = (ll)1e15;
                if (i != 1 && a[i - 1] == (ll)1e15)
                    cons = true;
            }
            else
                a[i] = stoi(s);
        }
        ll ma = 1e10, mi = -1e10;
        for (int i = 1; i <= N; i++)
        {
            if (a[i] != (ll)1e15)
                continue;
            if (i % 2)
            {
                // strictly smaller
                if (i - 1 >= 1)
                {
                    ma = min(ma, a[i - 1] - 1);
                }
                if (i + 1 <= N)
                {
                    ma = min(ma, a[i + 1] - 1);
                }
            }
            else
            {
                // strictly larger
                if (i - 1 >= 1)
                {
                    mi = max(mi, a[i - 1] + 1);
                }
                if (i + 1 <= N)
                {
                    mi = max(mi, a[i + 1] + 1);
                }
            }
        }

        if (cons)
        {
            cout << "none" << endl;
            continue;
        }

        if (cnt == 0)
        {
            bool f = true;
            for (int i = 1; i <= N; i++)
            {
                if (i % 2)
                {
                    if (i - 1 >= 1 && a[i - 1] <= a[i])
                    {
                        f = false;
                    }
                    if (i + 1 <= N && a[i + 1] <= a[i])
                    {
                        f = false;
                    }
                }
                else
                {
                    if (i - 1 >= 1 && a[i - 1] >= a[i])
                    {
                        f = false;
                    }
                    if (i + 1 <= N && a[i + 1] >= a[i])
                    {
                        f = false;
                    }
                }
            }
            if (f)
            {
                cout << "ambiguous" << endl;
            }
            else
            {
                cout << "none" << endl;
            }
            continue;
        }

        bool f = true;
        for (int i = 1; i <= N; i++)
        {
            if (a[i] == 1e15)
                continue;
            if (i % 2)
            {
                if (i - 1 >= 1 && a[i - 1] != 1e15 && a[i - 1] <= a[i])
                {
                    f = false;
                }
                if (i + 1 <= N && a[i + 1] != 1e15 && a[i + 1] <= a[i])
                {
                    f = false;
                }
            }
            else
            {
                if (i - 1 >= 1 && a[i - 1] != 1e15 && a[i - 1] >= a[i])
                {
                    f = false;
                }
                if (i + 1 <= N && a[i + 1] != 1e15 && a[i + 1] >= a[i])
                {
                    f = false;
                }
            }
        }
        if (!f)
        {
            cout << "none" << endl;
            continue;
        }

        //cout<<mi<<" "<<ma<<endl;

        if (mi == ma)
        {
            cout << mi << endl;
        }
        else if (mi < ma)
        {
            cout << "ambiguous" << endl;
        }
        else if (mi > ma)
        {
            cout << "none" << endl;
        }
        else
        {
            assert(false);
        }
    }
}



Measured memory_bytes: 3128