#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000001000
#define int long long
using namespace std;
signed main()
{
	int n;
	while (cin >> n, n)
	{
		//cout << "--------------------------------------------" << endl;
		//cout << n << endl;
		vector<int> vec(n + 1);
		string s;
		int seq = 0;
		bool none_flag = false;
		bool x = false;
		rep(i, n)
		{
			cin >> s;
			if (s == "x")
			{
				seq++;
				x = true;
				if ((i + 1) % 2 == 0)
					vec[i] = INF;
				else
					vec[i] = -INF;
			}
			else
			{
				seq = 0;
				vec[i] = atoi(s.c_str());
				if (i > 0 && (i + 1) % 2 == 0)
				{
					if (vec[i] <= vec[i - 1])
						none_flag = true;
				}
				if (i > 0 && (i + 1) % 2 == 1)
				{
					if (vec[i] >= vec[i - 1])
						none_flag = true;
				}
			}
			if (seq > 1)
				none_flag = true;
			//cout << s << " ";
		}
		//cout << endl;
		//cout << vec[0] << " " << vec[1] << endl;
		if (none_flag)
		{
			cout << "none" << endl;
			continue;
		}
		if (!x)
		{
			cout << "ambiguous" << endl;
			continue;
		}
		int sup = INF, inf = -INF;
		int max_tmp, min_tmp;
		rep(i, n)
		{
			if (vec[i] == INF || vec[i] == -INF)
			{
				if ((i + 1) % 2)
				{
					if (i == 0)
						max_tmp = vec[i + 1];
					else if (i == n - 1)
						max_tmp = vec[i - 1];
					else
						max_tmp = min(vec[i + 1], vec[i - 1]);
					sup = min(sup, max_tmp);
				}
				else
				{
					if (i == 0)
						min_tmp = vec[i + 1];
					else if (i == n - 1)
						min_tmp = vec[i - 1];
					else
						min_tmp = max(vec[i + 1], vec[i - 1]);
					inf = max(inf, min_tmp);
				}
			}
			//cout << inf << " " << sup << endl;
		}
		sup--;
		inf++;
		//cout << inf << " " << sup << endl;
		if (sup == inf)
			cout << sup << endl;
		else if (sup == -INF - 1 || inf == INF + 1)
			cout << "ambiguous" << endl;
		else if (inf < sup)
			cout << "ambiguous" << endl;
		else
			cout << "none" << endl;
	}
	return 0;
}

