loop {
	n = gets.to_i
	break if n == 0
	a = gets.chomp.split
	if a.each_cons(2).any?{|c1, c2| c1 == ?x && c2 == ?x}
		puts 'none'
		next
	end
	max = Float::INFINITY
	min = -max
	
	a.each_cons(2).with_index{|(c1, c2), i|
		if c1 == ?x
			if i.even?
				max = c2.to_i-1 if c2.to_i <= max
			else
				min = c2.to_i+1 if c2.to_i >= min
			end
		elsif c2 == ?x
			if i.even?
				min = c1.to_i+1 if c1.to_i >= min
			else
				max = c1.to_i-1 if c1.to_i <= max
			end
		else
			if i.even? && c1.to_i >= c2.to_i
				max = 0
				min = 1
				break
			end
			if i.odd? && c1.to_i <= c2.to_i
				max = 0
				min = 1
				break
			end
		end
	}

	if min == max
		puts min
	elsif min < max
		puts 'ambiguous'
	else
		puts 'none'
	end

}