#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

// string??????int????????????
long long int string_to_int(string str) {
    long long int length = str.length();
    bool seihu = true;
    if (str[0] == '-') {
        str = str.substr(1, length - 1);
        length--;
        seihu = false;
    }
    long long int number = 0;
    for (int i = 0; i < length; i++) {
        number += (long long int)(str[i] - '0');
        number *= 10;
    }
    number /= 10;
    if (seihu == false) {
        number *= (-1);
    }
    return number;
}

int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        Vec<string> str(n + 1);
        for (int i = 1; i <= n; i++) {
            cin >> str[i];
        }
        long long int upper_bound = -1e09 - 2;
        long long int lower_bound = +1e09 + 2;

        bool possible = true;
        bool change = false;

        string now;
        string next;

        for (int i = 1; i < n; i++) {
            now = str[i];
            next = str[i + 1];
            //cout << "I = " << i << endl;
            //cout << string_to_int(now) << " " << string_to_int(next) << endl;
            if (now == "x" && next == "x") {
                possible = false;
                //cout << "HERE1" << endl;
            } else if (now != "x" && next != "x") {
                if (i % 2 == 0) {
                    if (string_to_int(now) <= string_to_int(next)) {
                        possible = false;
                //cout << "HERE2" << endl;
                    }
                } else {
                    if (string_to_int(now) >= string_to_int(next)) {
                        possible = false;
                //cout << "HERE3" << endl;
                    }
                }
            } else if (now == "x" && next != "x") {
                if (i % 2 == 0) {
                    upper_bound = max(upper_bound, string_to_int(next) + 1);
                    change = true;
                } else {
                    lower_bound = min(lower_bound, string_to_int(next) - 1);
                    change = true;
                }
            } else {
                if (i % 2 == 0) {
                    lower_bound = min(lower_bound, string_to_int(now) - 1);
                    change = true;
                } else {
                    upper_bound = max(upper_bound, string_to_int(now) + 1);
                    change = true;
                }
            }
        }

        //cout << upper_bound << " " << lower_bound << endl;
        //cout << "POSSIBLE = " << possible << endl;
        if (possible == false || (upper_bound > lower_bound && change == true)) {
            cout << "none" << endl;
        } else if (upper_bound == lower_bound) {
            cout << upper_bound << endl;
        } else {
            cout << "ambiguous" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3068