loop do
    n = gets.to_i
    break if n == 0
    a = gets.split
    p = [-Float::INFINITY, Float::INFINITY]
    a.each_with_index do |aa,i|
        if aa == "x"
            if i < a.size - 1 && a[i+1] == "x"
                p = [Float::INFINITY, -Float::INFINITY]
                break
            end
            if i == 0
                p[1] = a[1].to_i - 1
            elsif i < a.size - 1
                if i % 2 == 1
                    p[0] = [[a[i-1].to_i, a[i+1].to_i].max + 1, p[0]].max
                else
                    p[1] = [[a[i-1].to_i, a[i+1].to_i].min - 1, p[1]].min
                end
            else
                if i % 2 == 1
                    p[0] = [a[i-1].to_i + 1, p[0]].max
                else
                    p[1] = [a[i-1].to_i - 1, p[1]].min
                end
            end
        else
            if i < a.size - 1 && a[i+1] != "x"
                if i % 2 == 1 && aa.to_i < a[i+1].to_i ||  i % 2 == 0 && aa.to_i > a[i+1].to_i
                    p = [Float::INFINITY, -Float::INFINITY]
                    break
                end
            end
        end
    end
    if p[0] == p[1]
        puts p[0]
    elsif p[0] > p[1]
        puts "none"
    else
        puts "ambiguous"
    end
end