from bisect import bisect_left

p = int(input())  # количество мест в вагоне
occupied = []     # список занятых мест

for _ in range(p):
    query = input()
    
    if query[0] == '-':
        _, seat = map(int, query.split())
        occupied.pop(bisect_left(occupied, seat))
    else:
        # ищем наиболее отдаленное свободное место
        if not occupied:  # если нет занятых мест
            seat = 1
        elif occupied[0] != 1:  # если первое место свободно
            seat = 1
        else:
            n = len(occupied)
            
            for i in range(n - 1):
                if occupied[i+1] - occupied[i] > 1:
                    seat = occupied[i] + 1
                    break
            else:
                seat = occupied[n-1] + 1
                
        occupied.insert(bisect_left(occupied, seat), seat)
        print(seat)