Tenten runs a weapon shop for ninjas. Today she is willing to sell $n$ shurikens which cost $1$, $2$, ..., $n$ ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is fairly simple: sometimes Tenten places another shuriken (from the available shurikens) on the showcase, and sometimes a ninja comes in and buys a shuriken from the showcase. Since ninjas are thrifty, they always buy the cheapest shuriken from the showcase.

Tenten keeps a record for all events, and she ends up with a list of the following types of records:

  + means that she placed another shuriken on the showcase;  - x means that the shuriken of price $x$ was bought. 

Today was a lucky day, and all shurikens were bought. Now Tenten wonders if her list is consistent, and what could be a possible order of placing the shurikens on the showcase. Help her to find this out!


-----Input-----

The first line contains the only integer $n$ ($1\leq n\leq 10^5$) standing for the number of shurikens. 

The following $2n$ lines describe the events in the format described above. It's guaranteed that there are exactly $n$ events of the first type, and each price from $1$ to $n$ occurs exactly once in the events of the second type.


-----Output-----

If the list is consistent, print "YES". Otherwise (that is, if the list is contradictory and there is no valid order of shurikens placement), print "NO".

In the first case the second line must contain $n$ space-separated integers denoting the prices of shurikens in order they were placed. If there are multiple answers, print any.


-----Examples-----
Input
4
+
+
- 2
+
- 3
+
- 1
- 4

Output
YES
4 2 3 1 

Input
1
- 1
+

Output
NO

Input
3
+
+
+
- 2
- 1
- 3

Output
NO



-----Note-----

In the first example Tenten first placed shurikens with prices $4$ and $2$. After this a customer came in and bought the cheapest shuriken which costed $2$. Next, Tenten added a shuriken with price $3$ on the showcase to the already placed $4$-ryo. Then a new customer bought this $3$-ryo shuriken. After this she added a $1$-ryo shuriken. Finally, the last two customers bought shurikens $1$ and $4$, respectively. Note that the order $[2, 4, 3, 1]$ is also valid.

In the second example the first customer bought a shuriken before anything was placed, which is clearly impossible.

In the third example Tenten put all her shurikens onto the showcase, after which a customer came in and bought a shuriken with price $2$. This is impossible since the shuriken was not the cheapest, we know that the $1$-ryo shuriken was also there.

Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Greedy algorithms
Skill types: Data structures

Greedy algorithms

Starter code:

Solutions:
l = []
n = int(input())
for _ in range(2 * n):
	l.append(input())
stk = []
visited = [False] * n
f = True
ans = []
for i in reversed(l):
	if i[0] == '+':
		if len(stk) == 0:
			f = False
			break
		t = stk.pop()
		ans.append(t)
		if visited[t - 1]:
			f = False
			break
		visited[t - 1] = True
	else:
		t = int(i[2:])
		if visited[t - 1]:
			f = False
			break
		if len(stk) > 0 and stk[-1] < t:
			f = False
			break
		stk.append(t)
if len(stk) != 0:
	f = False
if f:
	print('YES')
	print(*reversed(ans))
else:
	print('NO')


from collections import defaultdict as _defaultdict
import sys as _sys

def main():
	(n,) = _read_ints()
	events = _read_events(2 * n)
	try:
		result = restore_shurikens_order(events, n)
	except ValueError:
		print('NO')
	else:
		print('YES')
		print(*result)

def _read_events(events_n):
	for i_event in range(events_n):
		(event_type, *event_args) = _read_line().split(' ')
		if event_type == '+':
			assert len(event_args) == 0
			event = (PLACE_SHURIKEN_ID,)
		else:
			assert event_type == '-'
			assert len(event_args) == 1
			event = (BUY_SHURIKEN_ID, int(event_args[0]))
		yield event
PLACE_SHURIKEN_ID = 0
BUY_SHURIKEN_ID = 1

def restore_shurikens_order(events, shurikens_n):
	result = [None] * shurikens_n
	limits_tree = [0] * (shurikens_n + 1 + 1)
	limits_counter = _defaultdict(int)
	sources_by_limits = [[] for limit in range(shurikens_n + 1)]
	next_placement_index = 0
	for event in events:
		if event[0] == PLACE_SHURIKEN_ID:
			limit = 1
			_fenwick_add(limits_tree, limit, 1)
			sources_by_limits[limit].append(next_placement_index)
			limits_counter[limit] += 1
			next_placement_index += 1
		else:
			assert event[0] == BUY_SHURIKEN_ID
			item_to_buy = event[1]
			if _fenwick_prefix_sum(limits_tree, item_to_buy) == 0:
				raise ValueError('unable to restore shurikens order')
			limits_can_be_removed_n = _fenwick_prefix_sum(limits_tree, item_to_buy)
			min_limit_to_remove = 1
			max_limit_to_remove = item_to_buy
			while min_limit_to_remove != max_limit_to_remove:
				mid_limit_to_remove = min_limit_to_remove + max_limit_to_remove >> 1
				if limits_can_be_removed_n - _fenwick_prefix_sum(limits_tree, mid_limit_to_remove) == 0:
					max_limit_to_remove = mid_limit_to_remove
				else:
					min_limit_to_remove = mid_limit_to_remove + 1
			limit_to_remove = min_limit_to_remove
			_fenwick_add(limits_tree, limit_to_remove, -1)
			result[sources_by_limits[limit_to_remove].pop()] = item_to_buy
			limits_counter[limit_to_remove] -= 1
			moved_limits = _fenwick_move_all_before_to(limits_tree, item_to_buy)
			for limit in moved_limits:
				moved_n = limits_counter[limit]
				del limits_counter[limit]
				limits_counter[item_to_buy] += moved_n
				assert moved_n > 0
				sources_from = sources_by_limits[limit]
				sources_to = sources_by_limits[item_to_buy]
				assert len(sources_from) == moved_n
				if len(sources_from) > len(sources_to):
					(sources_to, sources_from) = (sources_from, sources_to)
					(sources_by_limits[item_to_buy], sources_by_limits[limit]) = (sources_to, sources_from)
				sources_to.extend(sources_from)
				sources_from.clear()
	return result

def _fenwick_prefix_sum(tree, index):
	index += 1
	result = 0
	while index != 0:
		result += tree[index]
		index -= index & -index
	return result

def _fenwick_add(tree, index, value):
	index += 1
	while index < len(tree):
		tree[index] += value
		index += index & -index

def _fenwick_move_all_before_to(tree, index_arg):
	index_arg += 1
	planned_additions = []
	index = index_arg
	while index < len(tree):
		father_last_i = index - (index & -index)
		segment_begin = father_last_i + 1
		planned_additions.append((index, _fenwick_prefix_sum(tree, segment_begin - 1 - 1)))
		index += index & -index
	queue_to_make_segments_zero = []
	i = index_arg - 1
	while i != 0:
		if tree[i] != 0:
			queue_to_make_segments_zero.append(i)
		i -= i & -i
	i_queue = 0
	while i_queue < len(queue_to_make_segments_zero):
		i = queue_to_make_segments_zero[i_queue]
		sum_in_that_segment_except_last = 0
		last_i_digit = i & -i
		j = i - (last_i_digit >> 1)
		if j != i:
			if tree[j] != 0:
				queue_to_make_segments_zero.append(j)
				sum_in_that_segment_except_last += tree[j]
			while j & 1 != 1:
				j += (j & -j) >> 1
				if tree[j] != 0:
					queue_to_make_segments_zero.append(j)
					sum_in_that_segment_except_last += tree[j]
		if i & 1 == 1 or tree[i] - sum_in_that_segment_except_last != 0:
			yield (i - 1)
		tree[i] = 0
		i_queue += 1
	for (index, value_to_add) in planned_additions:
		tree[index] += value_to_add

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split())
main()


n = int(input())
import heapq
tot = []
for i in range(2 * n):
	l = input()
	tot.append(l)
cur = []
heapq.heapify(cur)
can = True
for i in range(2 * n - 1, -1, -1):
	if tot[i][0] == '-':
		heapq.heappush(cur, int(tot[i][2:]))
	else:
		if len(cur) == 0:
			can = False
			break
		tot[i] = heapq.heappop(cur)
cur = []
if can:
	for i in tot:
		if isinstance(i, int) == False:
			if len(cur) == 0:
				can = False
				break
			k = int(i[2:])
			j = heapq.heappop(cur)
			if j != k:
				can = False
				break
		else:
			heapq.heappush(cur, i)
if can:
	print('YES')
	for t in tot:
		if isinstance(t, int):
			print(t, end=' ')
else:
	print('NO')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=-10 ** 6, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(50001)]
pp = []

def SieveOfEratosthenes(n=50000):
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for i in range(50001):
		if prime[i]:
			pp.append(i)
import heapq
data = []
for i in range(2 * int(input())):
	data.append(input().split())
avalible = []
result = []
try:
	for i in data[::-1]:
		if i[0] == '-':
			heapq.heappush(avalible, int(i[1]))
		else:
			m = heapq.heappop(avalible)
			result.append(m)
	result = result[::-1]
	avalible = []
	p = 0
	for i in data:
		if i[0] == '-':
			m = heapq.heappop(avalible)
			if m != int(i[1]):
				print('NO')
				sys.exit()
		else:
			heapq.heappush(avalible, result[p])
			p += 1
except Exception:
	print('NO')
	sys.exit()
print('YES')
print(*result)


class F:

	def __init__(self, x):
		self.bit = x
		for i in range(len(x)):
			j = i | i + 1
			if j < len(x):
				x[j] += x[i]

	def update(self, idx, x):
		while idx < len(self.bit):
			self.bit[idx] += x
			idx |= idx + 1

	def query(self, end):
		x = 0
		while end:
			x += self.bit[end - 1]
			end &= end - 1
		return x

	def findkth(self, k):
		idx = -1
		for d in reversed(range(len(self.bit).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(self.bit) and k >= self.bit[right_idx]:
				idx = right_idx
				k -= self.bit[idx]
		return idx + 1
import sys, io, os
Z = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
Y = lambda : print('NO') or quit()
n = int(Z())
o = [0] * n
c = 0
s = []
l = [[2 * n, 0]]
t = F([0] * n + [2 * n])
for _ in range(2 * n):
	v = Z().split()
	if len(v) > 1:
		b = int(v[1])
		if len(s) < 1 or b < l[-1][0]:
			Y()
		i = n - len(s) - t.query(len(s))
		if i + 1 < b:
			Y()
		t.update(n - b, 1)
		o[s.pop()] = b
		l[-1][1] -= 1
		if l[-1][1] < 1:
			v = l.pop()[0]
			if v > l[-1][0]:
				l[-1][0] = v
		if b > l[-1][0]:
			l[-1][0] = b
	else:
		s.append(c)
		c += 1
		if l[-1][0] > 0:
			l.append([0, 0])
		l[-1][1] += 1
print('YES')
print(' '.join(map(str, o)))


import heapq
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))
n = int(input())
inputOrder = []
taken = [False for _ in range(n + 1)]
currLargest = n
priority = []
inputs = []
for _ in range(n * 2):
	in_ = input().split()
	inputs.append(in_)
for zz in range(n * 2 - 1, -1, -1):
	in_ = inputs[zz]
	if len(in_) == 1:
		if priority:
			temp = priority.pop()
			inputOrder.append(temp)
			taken[temp] = True
		else:
			while taken[currLargest] == True:
				currLargest -= 1
			inputOrder.append(currLargest)
			taken[currLargest] = True
	else:
		priority.append(int(in_[1]))
inputOrder.reverse()
h = []
i = 0
possible = True
for zz in range(n * 2):
	in_ = inputs[zz]
	if len(in_) == 1:
		heapq.heappush(h, inputOrder[i])
		i += 1
	else:
		v = int(in_[1])
		if len(h) == 0:
			possible = False
			break
		else:
			v2 = heapq.heappop(h)
			if v != v2:
				possible = False
				break
if possible:
	print('YES')
	oneLineArrayPrint(inputOrder)
else:
	print('NO')


from heapq import *
import sys

def input():
	return sys.stdin.readline().rstrip()

def slv():
	n = int(input())
	que = []
	heapify(que)
	a = []
	ans = []
	MIN = 0
	order = []
	for _ in range(2 * n):
		X = list(input().split(' '))
		if X[0] == '+':
			order.append(('+', 0))
		else:
			order.append(('-', int(X[1])))
	for elem in order[::-1]:
		(X0, m) = elem
		if X0 == '+':
			if not que or not a:
				print('NO')
				return
			else:
				if a[-1] != que[0]:
					print('NO')
					return
				a.pop()
				ans.append(heappop(que))
		else:
			a.append(m)
			heappush(que, m)
			continue
	print('YES')
	print(*ans[::-1])
	return
slv()


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
seq = []
for i in range(2 * n):
	x = inp().split()
	if len(x) == 1:
		seq.append(x[0])
	else:
		seq.append(int(x[1]))
hp = []
flg = True
ansl = []
for x in seq[::-1]:
	if x == '+':
		if not hp:
			flg = False
			break
		ansl.append(heappop(hp))
	else:
		if hp:
			tmp = heappop(hp)
			if tmp < x:
				flg = False
				break
			heappush(hp, tmp)
		heappush(hp, x)
if flg:
	out('YES\n' + ' '.join(map(str, ansl[::-1])))
else:
	out('NO')


import sys
t = int(input())
c = [0] * t

def error():
	print('NO')
	raise SystemExit

def max2(a, b):
	if a > b:
		return a
	return b
v = [[10000000000.0, -1]]
index = 0
for _ in range(t + t):
	q = sys.stdin.readline()
	if q[0] == '+':
		v.append([0, index])
		index += 1
		continue
	n = int(q.split()[1])
	if v[-1][0] > n:
		error()
	c[v.pop()[1]] = n
	v[-1][0] = max2(n, v[-1][0])
print('YES')
print(' '.join(list(map(lambda x: str(x), c))))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
from heapq import *
n = II()
hp = []
tas = [SI().split() for _ in range(2 * n)]
ans = []
for ta in tas[::-1]:
	if ta[0] == '-':
		a = int(ta[1])
		heappush(hp, a)
	else:
		if not hp:
			print('NO')
			exit()
		a = heappop(hp)
		ans.append(a)
ans = ans[::-1]

def check():
	case = []
	i = 0
	for ta in tas:
		if ta[0] == '-':
			if not case:
				return False
			a = heappop(case)
			if a != int(ta[1]):
				return False
		else:
			heappush(case, ans[i])
			i += 1
	return True
if check():
	print('YES')
	print(*ans)
else:
	print('NO')


from sys import stdin
import sys
n = int(stdin.readline())
s = []
for i in range(2 * n):
	S = stdin.readline()[:-1]
	if S[0] == '+':
		s.append(('+', None))
	else:
		(t1, t2) = S.split()
		t2 = int(t2)
		s.append(('-', t2))
q = []
ans = []
for i in range(2 * n - 1, -1, -1):
	(t, num) = s[i]
	if t == '-':
		if len(q) > 0 and q[-1] < num:
			print('NO')
			sys.exit()
		else:
			q.append(num)
	elif len(q) == 0:
		print('NO')
		sys.exit()
	else:
		ans.append(q[-1])
		del q[-1]
print('YES')
ans.reverse()
print(*ans)


import heapq
import sys
input = sys.stdin.readline
for _ in range(1):
	n = int(input())
	ans = [0] * n
	flag = 0
	mi = []
	ma = []
	cnt = -1
	heapq.heapify(mi)
	heapq.heapify(ma)
	ind = -1
	o = []
	for i in range(2 * n):
		l = list(map(str, input().split()))
		o.append(l)
		if len(l) == 1:
			ind += 1
			heapq.heappush(ma, -1 * ind)
		else:
			x = int(l[-1])
			if len(ma) != 0:
				u = -1 * heapq.heappop(ma)
				ans[u] = x
			else:
				flag = 1
	if flag:
		print('NO')
		continue
	ind = -1
	for i in o:
		l = i
		if len(l) == 1:
			ind += 1
			heapq.heappush(mi, ans[ind])
		else:
			x = int(l[-1])
			if x != mi[0]:
				flag = 1
			else:
				heapq.heappop(mi)
	if flag:
		print('NO')
		continue
	print('YES')
	print(*ans)


from heapq import *
n = int(input())
ok = True
listed = 0
queries = []
prev = -1
for i in range(2 * n):
	q = input().strip().split()
	if len(q) == 2:
		listed -= 1
		if int(q[1]) >= prev:
			prev = int(q[1])
		else:
			ok = False
			break
	else:
		listed += 1
		prev = -1
	ok &= listed >= 0
	queries.append(q)
	if not ok:
		break
if not ok:
	print('NO')
else:
	ans = []
	queue = []
	heapify(queue)
	for i in range(2 * n - 1, -1, -1):
		if len(queries[i]) == 2:
			heappush(queue, int(queries[i][1]))
		else:
			ans.append(heappop(queue))
	ptr = len(ans) - 1
	validate = []
	heapify(validate)
	for i in queries:
		if len(i) == 2:
			e = heappop(validate)
			if e != int(i[1]):
				ok = False
				break
		else:
			heappush(validate, ans[ptr])
			ptr -= 1
	if ok:
		print('YES')
		print(*ans[::-1])
	else:
		print('NO')


import sys
import heapq
input = sys.stdin.readline
data = []
for i in range(2 * int(input())):
	data.append(input().split())
q = []
result = []
for i in data[::-1]:
	if i[0] == '-':
		heapq.heappush(q, int(i[1]))
	elif q:
		m = heapq.heappop(q)
		result.append(m)
	else:
		print('NO')
		sys.exit()
result = result[::-1]
q = []
current = 0
for i in data:
	if i[0] == '-':
		m = heapq.heappop(q)
		if m != int(i[1]):
			print('NO')
			sys.exit()
	else:
		heapq.heappush(q, result[current])
		current += 1
print('YES')
print(*result)


import io
import os
from collections import Counter, defaultdict, deque

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def solve(N, events):
	assert len(events) == 2 * N
	ans = [-1 for i in range(2 * N)]
	place = SortedList()
	for (i, e) in enumerate(events):
		if e == -1:
			place.add(i)
	order = list(range(len(events)))
	order.sort(key=lambda i: events[i])
	for i in order:
		if events[i] > 0:
			index = place.bisect_left(i) - 1
			if index >= 0:
				j = place[index]
				del place[index]
				assert events[j] == -1
				ans[j] = events[i]
			else:
				return 'NO'
	if place:
		return 'NO'
	for (i, e) in enumerate(events):
		if e == -1:
			place.add(ans[i])
		else:
			x = place.pop(0)
			if x != e:
				return 'NO'
	return 'YES\n' + ' '.join((str(x) for x in ans if x != -1))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N,) = [int(x) for x in input().split()]
events = []
for i in range(2 * N):
	event = input().decode().strip()
	if event[0] == '+':
		events.append(-1)
	else:
		events.append(int(event.split(' ')[-1]))
ans = solve(N, events)
print(ans)


import sys, heapq
input = sys.stdin.readline
n = int(input())
stack = []
(f, c) = (0, 0)
res = [0 for _ in range(n)]
inp = []
for i in range(2 * n):
	s = input().strip()
	inp.append(s)
	if s[0] == '+':
		stack.append(c)
		c += 1
	elif not stack:
		f = 1
		break
	else:
		cur = stack.pop()
		res[cur] = int(s[2:])
if f == 0:
	temp = []
	(c, f) = (0, 0)
	for i in range(2 * n):
		if inp[i][0] == '+':
			heapq.heappush(temp, res[c])
			c += 1
		elif int(inp[i][2:]) != heapq.heappop(temp):
			f = 1
			break
	if f == 0:
		sys.stdout.write('YES' + '\n')
		for i in res:
			sys.stdout.write(str(i) + ' ')
	else:
		sys.stdout.write('NO' + '\n')
else:
	sys.stdout.write('NO' + '\n')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(RL())

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	n = N()
	rec = [-1 for _ in range(n)]
	st = []
	now = 0
	al = []
	for _ in range(2 * n):
		s = input()
		al.append(s)
		if s[0] == '+':
			st.append(now)
			now += 1
		else:
			pric = int(s[2:])
			if not st:
				print('NO')
				break
			ind = st.pop()
			rec[ind] = pric
	else:
		ind = 0
		hp = []
		for i in al:
			if i[0] == '+':
				heappush(hp, rec[ind])
				ind += 1
			else:
				now = heappop(hp)
				if int(i[2:]) != now:
					print('NO')
					break
		else:
			print('YES')
			print(*rec)
main()


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import deque
N = int(input())
ans = [None] * N
(empty_pos, ok) = (deque(), False)
monoidx = 0
for tt in range(2 * N):
	inp = input()
	if inp[0] == '+':
		empty_pos.append(monoidx)
		monoidx += 1
	else:
		(_, num) = inp.split()
		num = int(num)
		if not empty_pos:
			break
		idx = empty_pos.pop()
		if idx < N - 1 and (ans[idx + 1] is not None and ans[idx + 1] > num):
			break
		ans[idx] = num
else:
	ok = True and all(ans) and (len(set(ans)) == N)
if not ok:
	print('NO')
else:
	print('YES')
	print(*ans)


import sys
input = sys.stdin.readline
import heapq
n = int(input())
tmp = [list(input().split()) for i in range(2 * n)]
info = [-1] * (2 * n)
for (i, q) in enumerate(tmp):
	if q[0] == '-':
		val = int(q[1])
		info[i] = val
hq = []
p = [-1] * (2 * n)
i = 2 * n
for val in info[::-1]:
	i -= 1
	if val != -1:
		heapq.heappush(hq, val)
	else:
		if not hq:
			print('NO')
			exit()
		val = heapq.heappop(hq)
		p[i] = val
hq = []
res = []
for i in range(2 * n):
	if p[i] != -1:
		heapq.heappush(hq, p[i])
		res.append(p[i])
	else:
		val = heapq.heappop(hq)
		if val != info[i]:
			print('NO')
			exit()
print('YES')
print(' '.join(map(str, res)))


import sys
import heapq
input = sys.stdin.readline
data = []
for i in range(2 * int(input())):
	data.append(input().split())
avalible = []
result = []
try:
	for i in data[::-1]:
		if i[0] == '-':
			heapq.heappush(avalible, int(i[1]))
		else:
			m = heapq.heappop(avalible)
			result.append(m)
	result = result[::-1]
	avalible = []
	p = 0
	for i in data:
		if i[0] == '-':
			m = heapq.heappop(avalible)
			if m != int(i[1]):
				print('NO')
				sys.exit()
		else:
			heapq.heappush(avalible, result[p])
			p += 1
except Exception:
	print('NO')
	sys.exit()
print('YES')
print(*result)


n = int(input())
ans = [0] * n
val = []
st = []
temp = 'YES'
c = -1
for _ in range(0, 2 * n):
	s = input().split()
	if s[0] == '+':
		c += 1
		st.append(0)
		val.append(c)
	else:
		tt = int(s[1])
		if len(st) == 0:
			temp = 'NO'
		else:
			if st[-1] > tt:
				temp = 'NO'
			ptr = val.pop()
			ans[ptr] = tt
			tt2 = st.pop()
			if len(st) > 0:
				st[-1] = max(st[-1], tt, tt2)
print(temp)
if temp == 'YES':
	print(*ans)


from bisect import bisect_right, bisect_left
import sys
input = sys.stdin.readline

def main():
	n = int(input())
	pm = 0
	lst = []
	for _ in range(2 * n):
		s = input().strip().split()
		if s[0] == '+':
			pm += 1
			lst.append(-1)
		else:
			pm -= 1
			lst.append(int(s[1]))
			if pm < 0:
				print('NO')
				return
	ans = []
	que = []
	for i in lst[::-1]:
		if i == -1:
			ans.append(que.pop())
		else:
			if que and que[-1] < i:
				print('NO')
				return
			que.append(i)
	print('YES')
	print(*ans[::-1])
main()


import sys, bisect
input = sys.stdin.readline
n = int(input())
sell = []
pos = [-1 for i in range(n)]
rest_left = [i - 1 for i in range(2 * n)]
rest_right = [i + 1 for i in range(2 * n)]
for i in range(2 * n):
	s = input().split()
	if s[0] == '+':
		continue
	else:
		sell.append(i)
		pos[int(s[1]) - 1] = len(sell) - 1
left = [i - 1 for i in range(n)]
right = [i + 1 for i in range(n)]
res = [-1 for i in range(2 * n)]
for i in range(n):
	R = sell[pos[i]]
	if left[pos[i]] != -1:
		L = sell[left[pos[i]]]
	else:
		L = -1
	sold = rest_left[R]
	if L < sold:
		res[sold] = i + 1
		if rest_right[sold] < 2 * n:
			rest_left[rest_right[sold]] = rest_left[sold]
		if rest_left[sold] != -1:
			rest_right[rest_left[sold]] = rest_right[sold]
		if rest_right[R] < 2 * n:
			rest_left[rest_right[R]] = rest_left[R]
		if rest_left[sold] != -1:
			rest_right[rest_left[R]] = rest_right[R]
		if right[pos[i]] < n:
			left[right[pos[i]]] = left[pos[i]]
		if left[pos[i]] != -1:
			right[left[pos[i]]] = right[pos[i]]
	else:
		exit(print('NO'))
ans = []
for a in res:
	if a != -1:
		ans.append(a)
print('YES')
print(*ans)


import sys
import heapq
input = sys.stdin.readline

def main():
	N = int(input())
	S = [[x for x in input().split()] for _ in range(2 * N)]
	q = []
	ans = []
	for s in S[::-1]:
		if s[0] == '-':
			heapq.heappush(q, int(s[1]))
		elif q:
			c = heapq.heappop(q)
			ans.append(c)
		else:
			print('NO')
			return
	ans2 = ans[::-1]
	q = []
	current = 0
	for s in S:
		if s[0] == '-':
			c = heapq.heappop(q)
			if c != int(s[1]):
				print('NO')
				return
		else:
			heapq.heappush(q, ans2[current])
			current += 1
	print('YES')
	print(*ans2)
main()


import sys
input = sys.stdin.readline
n = int(input())
a = [0] * n
q = []
limit = []
cnt = 0
vio = False
query = []
for i in range(2 * n):
	query.append(input())
for i in range(2 * n):
	if len(query[i]) == 2:
		q.append(cnt)
		cnt += 1
		if len(limit) > 0 and limit[-1][0] == 1:
			limit[-1][1] += 1
		else:
			limit.append([1, 1])
	else:
		(m, x) = query[i].split()
		if len(limit) == 0 or limit[-1][0] > int(x):
			vio = True
			break
		p = q.pop()
		a[p] = int(x)
		limit[-1][1] -= 1
		c = 0
		while len(limit) > 0 and limit[-1][0] <= int(x) + 1:
			c += limit[-1][1]
			limit.pop()
		if c != 0:
			limit.append([int(x) + 1, c])
if vio:
	print('NO')
else:
	print('YES')
	print(*a)


def read_seq(v):
	seq = []
	for i in range(2 * v):
		s = input().split()
		if len(s) == 2:
			s[1] = int(s[1])
		seq.append(s)
	return seq

def solve():
	n = int(input())
	pos = [-1] * (2 * n)
	stack = []
	seq = read_seq(n)
	for (i, act) in enumerate(seq):
		if act[0] == '+':
			stack.append(i)
		elif not stack:
			return None
		else:
			v = stack.pop()
			pos[v] = act[1]
	if stack:
		return None
	stack = []
	for (i, act) in enumerate(seq):
		if act[0] == '+':
			if stack and stack[-1] < pos[i]:
				return None
			else:
				stack.append(pos[i])
		else:
			stack.pop()
	return [x for x in pos if x != -1]

def main():
	res = solve()
	if res:
		print('YES')
		print(' '.join(map(str, res)))
	else:
		print('NO')
main()


import sys
readline = sys.stdin.readline
from heapq import heappop as hpp, heappush as hp
N = int(readline())
ev = [None] * (2 * N)
pl = []
ans = 'YES'
for i in range(2 * N):
	s = readline().strip()
	if s[0] == '+':
		pl.append(i)
	elif not pl:
		ans = 'NO'
	else:
		b = int(s.split()[1])
		ev[i] = b
		ev[pl.pop()] = -b
if ans == 'NO':
	print(ans)
else:
	Q = []
	for i in ev:
		if i < 0:
			i = -i
			hp(Q, i)
		elif i != hpp(Q):
			ans = 'NO'
			break
	print(ans)
	if ans == 'YES':
		print(*[-i for i in ev if i < 0])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
n = N()
res = [0] * (n + 2)
d = []
now = 0
flag = True
for _ in range(2 * n):
	s = input().strip()
	if s == '+':
		d.append(now)
		now += 1
	else:
		v = int(s[2:])
		if not d:
			flag = False
			break
		t = d.pop()
		if v < res[t + 1]:
			flag = False
			break
		res[t] = v
if not flag:
	print('NO')
else:
	print('YES')
	print_list(res[:n])


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from heapq import heappush, heappop
N = int(input())
E = []
for _ in range(2 * N):
	e = input()
	if e == '+':
		E.append(-1)
	else:
		E.append(int(e[2:]))
Ans = []
q = []
for e in reversed(E):
	if e == -1:
		if not q:
			print('NO')
			exit()
		v = heappop(q)
		Ans.append(v)
	else:
		heappush(q, e)
Ans.reverse()
iter_Ans = iter(Ans)
for e in E:
	if e == -1:
		heappush(q, next(iter_Ans))
	else:
		v = heappop(q)
		if v != e:
			print('NO')
			exit()
print('YES')
print(' '.join(map(str, Ans)))


N = int(input())
Q = []
for i in range(N * 2):
	Q.append(input())
Q = Q[::-1]
stack = []
ans = []
for q in Q:
	if len(q) == 1:
		if not stack:
			print('NO')
			exit()
		a = stack.pop()
		ans.append(a)
	else:
		(m, a) = q.split()
		a = int(a)
		if stack and stack[-1] < a:
			print('NO')
			exit()
		stack.append(a)
print('YES')
print(*ans[::-1])


import sys
input = sys.stdin.readline
import heapq
n = int(input())
Q = [input().split() for i in range(2 * n)]
ANS = []
H = []
for T in Q[::-1]:
	if T[0] == '+':
		if len(H) == 0:
			print('NO')
			sys.exit()
		else:
			h = heapq.heappop(H)
			ANS.append(h)
	else:
		(_, x) = T
		heapq.heappush(H, int(x))
ANS.reverse()
i = 0
H = []
for T in Q:
	if T[0] == '+':
		heapq.heappush(H, ANS[i])
		i += 1
	else:
		(_, x) = T
		h = heapq.heappop(H)
		if h != int(x):
			print('NO')
			sys.exit()
print('YES')
print(*ANS)


import sys
input = sys.stdin.readline
from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

class SegmentTree(object):

	def __init__(self, N):
		self.N = N
		self.N0 = 2 ** (N - 1).bit_length()
		self.initVal = INF
		self.data = [self.initVal] * (2 * self.N0)

	def calc(self, a, b):
		return min(a, b)

	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.calc(self.data[2 * k + 1], self.data[2 * k + 2])

	def query(self, l, r):
		L = l + self.N0
		R = r + self.N0 + 1
		m = self.initVal
		while L < R:
			if R & 1:
				R -= 1
				m = self.calc(m, self.data[R - 1])
			if L & 1:
				m = self.calc(m, self.data[L - 1])
				L += 1
			L >>= 1
			R >>= 1
		return m

def main():
	N = int(input())
	Q = []
	for i in range(2 * N):
		q = list(input().rstrip().split())
		Q.append(q)
	Q.reverse()
	cnt = 0
	ans = 1
	L = []
	Seg = SegmentTree(N + 1)
	for q in Q:
		if q[0] == '+':
			cnt += 1
			if cnt > 0:
				ans = 0
				break
			val = Seg.query(0, N)
			Seg.update(val, INF)
			L.append(val)
		else:
			cnt -= 1
			x = int(q[1])
			m = Seg.query(0, N)
			if x > m:
				ans = 0
				break
			Seg.update(x, x)
	if ans == 0:
		print('NO')
	else:
		L.reverse()
		print('YES')
		print(*L)
main()


import sys
import heapq
input = sys.stdin.readline
n = int(input())
a = [-1] * n
st = []
t = 0
flag = True
comands = []
for i in range(2 * n):
	comand = input().split()
	comands.append(comand)
	if comand[0] == '+':
		st.append(t)
		t += 1
	elif len(st) == 0:
		flag = False
	else:
		i = int(comand[1])
		j = st.pop()
		a[j] = i
if len(st) != 0:
	flag = False
h = []
heapq.heapify(h)
pos = 0
for i in range(2 * n):
	comand = comands[i]
	if comand[0] == '+':
		heapq.heappush(h, a[pos])
		pos += 1
	elif len(h) > 0:
		x = heapq.heappop(h)
		if x != int(comand[1]):
			flag = False
	else:
		flag = False
if not flag:
	print('NO')
else:
	print('YES')
	print(*a)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq
n = int(input())
ans = ['x' for s in range(n)]
store = []
broke = False
c = 0
order = []
for s in range(2 * n):
	inf = input().split()
	if inf[0] == '+':
		store.append(c)
		c += 1
		order.append('+')
	else:
		num = int(inf[1])
		if len(store) > 0:
			ans[store.pop()] = num
		else:
			broke = True
		order.append(num)
if broke == False:
	minheap = []
	count = 0
	for s in range(2 * n):
		if order[s] == '+':
			heapq.heappush(minheap, ans[count])
			count += 1
		else:
			num = heapq.heappop(minheap)
			if num == order[s]:
				continue
			else:
				broke = True
				break
if broke == False:
	print('YES')
	print(*ans)
else:
	print('NO')


import sys, os, io
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
n = int(input())
h = []
i = 0
ans = [0] * n
flag = 0
check = []
mini = [10 ** 9] * n
prev = 0
for _ in range(2 * n):
	s = input().strip()
	if flag == 1:
		continue
	if s[0] == '+':
		check = []
		heappush(h, i)
		i -= 1
	else:
		if len(h) == 0:
			flag = 1
			continue
		num = int(s.split()[1])
		ind = heappop(h)
		ans[-ind] = num
		if len(check) == 0:
			for j in range(-ind, prev - 1, -1):
				mini[j] = num
			prev = -ind + 1
		if len(check) != 0 and check[-1] > num:
			flag = 1
		check.append(num)
for i in range(n):
	if ans[i] < mini[i]:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')
	print(*ans)


import heapq
from sys import exit
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
heap = []
queries = []
for _ in range(2 * n):
	queries.append(input().split())
queries.reverse()
the_order_of_the_shuriken = []
for query in queries:
	if query[0].decode() == '-':
		if heap and heap[0] < int(query[1].decode()):
			exit(print('NO'))
		heapq.heappush(heap, int(query[1].decode()))
	else:
		if not heap:
			exit(print('NO'))
		the_order_of_the_shuriken.append(heapq.heappop(heap))
the_order_of_the_shuriken.reverse()
print('YES')
print(*the_order_of_the_shuriken)


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import heapq

def check(a, ev):
	h = []
	heapq.heapify(h)
	i = 0
	bol = 1
	for t in ev:
		if t[0] == '+':
			heapq.heappush(h, a[i])
			i += 1
		else:
			if not h:
				bol = 0
				break
			if int(t[1]) != heapq.heappop(h):
				bol = 0
				break
	return bol
n = int(input())
s = set()
for i in range(1, n + 1):
	s.add(i)
ans = []
stack = []
ANS = 1
ev = []
for _ in range(2 * n):
	t = list(input().split())
	ev.append(t)
	if t[0] == '+':
		ans.append([-1])
		stack.append(len(ans) - 1)
	elif stack:
		ans[stack.pop()] = int(t[1])
	else:
		ANS = 0
		break
if ANS:
	if check(ans, ev):
		print('YES')
		print(*ans)
	else:
		print('NO')
else:
	print('NO')


import heapq
n = int(input())
s = ''
a = []
for _ in range(2 * n):
	l = [x for x in input().split()]
	if l[0] == '+':
		s += '+'
	else:
		s += '-'
		a.append(int(l[1]))

def helper():
	ind = n - 1
	pq = []
	ans = []
	for i in range(2 * n - 1, -1, -1):
		if s[i] == '+':
			if len(pq) == 0:
				print('NO')
				return
			else:
				ans.append(pq[0])
				heapq.heappop(pq)
		elif len(pq) == 0:
			heapq.heappush(pq, a[ind])
			ind -= 1
		elif pq[0] < a[ind]:
			print('NO')
			return
		else:
			heapq.heappush(pq, a[ind])
			ind -= 1
	print('YES')
	for i in ans[::-1]:
		print(i, end=' ')
	return
helper()


n = int(input())
query = []
for i in range(2 * n):
	a = input().split()
	if a[0] == '+':
		query.append(0)
	else:
		query.append(int(a[1]))
stack = []
out = []
ans = 'YES'
if query[-1] == 0:
	ans = 'NO'
else:
	stack.append(query.pop())
	while query:
		if not stack and query[-1] == 0 or (stack and stack[-1] < query[-1]):
			ans = 'NO'
			break
		elif query[-1] > 0:
			stack.append(query.pop())
		else:
			_ = query.pop()
			out.append(stack.pop())
print(ans)
if ans == 'YES':
	print(*out[::-1])


import sys, heapq
n = int(input())
stack = []
(f, c) = (0, 0)
res = [0 for _ in range(n)]
inp = []
for i in range(2 * n):
	s = input()
	inp.append(s)
	if s[0] == '+':
		stack.append(c)
		c += 1
	elif not stack:
		f = 1
		break
	else:
		cur = stack.pop()
		res[cur] = int(s[2:])
if f == 0:
	temp = []
	(c, f) = (0, 0)
	for i in range(2 * n):
		if inp[i][0] == '+':
			heapq.heappush(temp, res[c])
			c += 1
		elif int(inp[i][2:]) != heapq.heappop(temp):
			f = 1
			break
	if f == 0:
		print('YES')
		print(*res)
	else:
		print('NO')
else:
	print('NO')


import sys
import heapq
input = sys.stdin.readline

def main():
	data = []
	for i in range(2 * int(input())):
		data.append(input().split())
	avalible = []
	result = []
	for i in data[::-1]:
		if i[0] == '-':
			heapq.heappush(avalible, int(i[1]))
		elif avalible:
			m = heapq.heappop(avalible)
			result.append(m)
		else:
			print('NO')
			return
	result = result[::-1]
	avalible = []
	p = 0
	for i in data:
		if i[0] == '-':
			m = heapq.heappop(avalible)
			if m != int(i[1]):
				print('NO')
				return
		else:
			heapq.heappush(avalible, result[p])
			p += 1
	print('YES')
	print(*result)
main()


import heapq
import sys
input = sys.stdin.readline
n = int(input())
qe = []
hq = []
res = []
for i in range(n * 2):
	qe.append(input())
qe.reverse()
for q in qe:
	if len(q) >= 3:
		(t, b) = q.split()
		if len(hq) > 0 and int(b) > hq[0]:
			print('NO')
			exit(0)
		heapq.heappush(hq, int(b))
	else:
		if len(hq) == 0:
			print('NO')
			exit(0)
		res.append(heapq.heappop(hq))
print('YES')
print(*reversed(res))


n = int(input())
a = [input() for _ in range(2 * n)]
q = []
ans = []
for line in a[::-1]:
	if line == '+':
		if q == []:
			print('NO')
			exit(0)
		else:
			ans.append(q[-1])
			q.pop()
	else:
		r = line.split()
		r[1] = int(r[1])
		if q != [] and r[1] > q[-1]:
			print('NO')
			exit(0)
		else:
			q.append(r[1])
print('YES')
print(*ans[::-1])


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations, combinations

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = 10 ** 9
mod = int(1000000000.0) + 7

def construct(BIT, arr):
	for i in range(len(arr)):
		BIT[i + 1] = arr[i]

def updateBIT(BIT, v, w):
	while v <= n:
		BIT[v] += w
		v += v & -v

def getvalue(BIT, v):
	ANS = 0
	while v != 0:
		ANS += BIT[v]
		v -= v & -v
	return ANS

def bisect_on_BIT(BIT, x):
	if x <= 0:
		return 0
	ANS = 0
	h = 1 << n - 1
	while h > 0:
		if ANS + h <= n and BIT[ANS + h] < x:
			x -= BIT[ANS + h]
			ANS += h
		h //= 2
	return ANS + 1

def update(BIT, l, r, n, val):
	updateBIT(BIT, l, val)
	updateBIT(BIT, r + 1, -val)
n = int(input())
BIT = [0] * (n + 1)
stack = []
ans = [0] * n
cnt = 0
a = [data().split() for i in range(2 * n)]
for i in range(2 * n):
	if a[i][0] == '+':
		stack.append([cnt, 0])
		cnt += 1
	else:
		x = int(a[i][1])
		if stack and n - x - (getvalue(BIT, n) - getvalue(BIT, x)) >= len(stack) - 1 and (stack[-1][1] < x):
			(p, q) = stack.pop()
			ans[p] = x
			updateBIT(BIT, x, 1)
			if stack:
				stack[-1][1] = max(stack[-1][1], q, x)
		else:
			out('NO')
			exit()
if stack:
	out('NO')
	exit()
out('YES')
outl(ans)


import heapq
import sys
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
res = []
for i in range(2 * n):
	res.append(list(map(str, input().split())))
ans = []
ord = []
res.reverse()
for j in res:
	if j[0] == '-':
		heapq.heappush(ord, int(j[1]))
	elif ord != []:
		ans.append(heapq.heappop(ord))
ans.reverse()
res.reverse()
val = []
i = 0
for j in res:
	if j[0] == '+':
		heapq.heappush(val, ans[i])
		i += 1
	elif val != []:
		p = heapq.heappop(val)
		if p != int(j[1]):
			print('NO')
			sys.exit()
	else:
		print('NO')
		sys.exit()
print('YES')
print(*ans)


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from heapq import heappush, heappop
n = int(input())
ops = [input() for _ in range(n + n)]
queue = []
ans = []
for i in range(2 * n - 1, -1, -1):
	if ops[i][0] == '+':
		if not queue:
			print('NO')
			exit(0)
		ans.append(heappop(queue))
	else:
		val = int(ops[i].split()[1])
		if queue and val > queue[0]:
			print('NO')
			exit(0)
		heappush(queue, val)
print('YES')
print(' '.join((str(x) for x in reversed(ans))))


import sys
input = sys.stdin.readline
n = int(input())
events = []
for i in range(2 * n):
	x = input()
	if x == '+\n':
		events.append([0])
	else:
		(x, y) = x.split()
		events.append([1, int(y)])
poss = True
shelf = []
placed = []
while len(events) > 0:
	ev = events.pop()
	if ev[0] == 0:
		if len(shelf) == 0:
			poss = False
			break
		x = shelf.pop()
		placed.append(x)
	else:
		x = ev[1]
		if len(shelf) > 0 and shelf[-1] < x:
			poss = False
			break
		shelf.append(x)
if poss:
	cpl = [0] * n
	for i in range(n):
		cpl[i] = placed[-i - 1]
	print('YES')
	print(*cpl)
else:
	print('NO')


t = int(input())
c = [0] * t

def error():
	print('NO')
	raise SystemExit
v = []
index = 0
for _ in range(t + t):
	q = input()
	if q[0] == '+':
		v.append([0, index])
		index += 1
		continue
	n = int(q.split()[1])
	if len(v) == 0:
		error()
	if v[-1][0] > n:
		error()
	c[v.pop()[1]] = n
	if len(v) != 0:
		v[-1][0] = max(n, v[-1][0])
print('YES')
print(' '.join(list(map(lambda x: str(x), c))))


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint
mod = 1000000007

def main():
	n = int(input())
	a = []
	for i in range(2 * n):
		a.append(input().split())
	(b, c, f) = ([], [], 1)
	heapify(c)
	for i in range(2 * n - 1, -1, -1):
		if len(a[i]) == 2:
			a[i][1] = int(a[i][1])
			heappush(c, a[i][1])
		else:
			if c == []:
				f = 0
				break
			b.append(heappop(c))
	if f:
		b.reverse()
		j = 0
		d = []
		for i in range(2 * n):
			if len(a[i]) == 1:
				d.append(b[j])
				j += 1
			else:
				if d == [] or d[-1] != a[i][1]:
					f = 0
					break
				d.pop()
		if f:
			print('YES')
			print(*b)
		else:
			print('NO')
	else:
		print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
PLUS = '+'
MINUS = '-'

def solve():
	n = int(input())
	sales = []
	for _ in range(2 * n):
		sales.append(input().split(' '))
	min_queue = []
	res = []
	for i in range(2 * n - 1, -1, -1):
		if sales[i][0] == MINUS:
			current_sale = int(sales[i][1])
			if len(min_queue) == 0 or current_sale < min_queue[-1]:
				min_queue.append(int(sales[i][1]))
			else:
				return ('NO', None)
		elif len(min_queue) == 0:
			return ('NO', None)
		else:
			res.append(min_queue.pop())
	return ('YES', res[::-1])
(a, b) = solve()
print(a)
if b != None:
	print(' '.join(map(str, b)))


import os
import sys
from io import BytesIO, IOBase
import heapq

def main():
	n = int(input())
	Q = [input().split() for _ in range(2 * n)]
	ans = []
	h = []
	for q in Q[::-1]:
		if q[0] == '+':
			if len(h) == 0:
				print('NO')
				exit()
			ele = heapq.heappop(h)
			ans.append(ele)
		else:
			(_, t) = q
			heapq.heappush(h, int(t))
	ans.reverse()
	h = []
	i = 0
	for q in Q:
		if q[0] == '+':
			heapq.heappush(h, ans[i])
			i += 1
		else:
			(_, ele) = q
			if int(ele) != heapq.heappop(h):
				print('NO')
				exit()
	print('YES')
	print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import heapq
n = int(input())
a = []
ans = []
pq = []
string = ''
for i in range(2 * n):
	s = input().split()
	string += s[0]
	if s[0] == '-':
		a.append(int(s[-1]))
for j in range(2 * n - 1, -1, -1):
	if string[j] == '+':
		if not pq:
			print('NO')
			exit()
		else:
			ans.append(heapq.heappop(pq))
	elif not pq:
		heapq.heappush(pq, a.pop(-1))
	else:
		zx = heapq.heappop(pq)
		heapq.heappush(pq, zx)
		if zx < a[-1]:
			print('NO')
			exit()
		else:
			heapq.heappush(pq, a.pop(-1))
print('YES')
print(*reversed(ans))


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
n = I()
ind = [0] * (n + 1)
v = [i for i in range(n + 1)]
a = [0]
id = 0
k = n
flg = 0
ans = [0] * (n + 1)
c = [1] * (n + 1)
for i in range(2 * n):
	s = S().split()
	if s[0] == '+':
		while not c[v[-1]]:
			v.pop()
		a += (v.pop(),)
		c[a[-1]] = 0
		ind[a[-1]] = id
		id += 1
		flg = 0
	else:
		x = int(s[-1])
		if not a[-1]:
			exit(print('NO'))
		if flg:
			if a[-1] >= x > flg:
				v += (a[-1],)
				c[a[-1]] = 1
				c[x] = 0
				if x > ans[ind[a[-1]] + 1]:
					ans[ind[a.pop()]] = x
				else:
					exit(print('NO'))
			else:
				exit(print('NO'))
		elif a[-1] >= x:
			v += (a[-1],)
			c[a[-1]] = 1
			c[x] = 0
			if x > ans[ind[a[-1]] + 1]:
				ans[ind[a.pop()]] = x
			else:
				exit(print('NO'))
		else:
			exit(print('NO'))
		flg = x
print('YES')
print(*ans[:-1])


import os
import sys
from io import BytesIO, IOBase
import heapq

def main():
	n = int(input())
	a = [input() for x in range(2 * n)]
	a.reverse()
	pq = []
	chk = 0
	ans = []
	temp = []
	for x in a:
		if x == '+':
			if len(pq) == 0:
				chk = 1
				break
			else:
				topop = heapq.heappop(pq)
				ans.append(topop)
		else:
			heapq.heappush(pq, int(x.split(' ')[1]))
	if chk == 1:
		print('NO')
	else:
		ans.reverse()
		temp = []
		cnt = 0
		a.reverse()
		for x in a:
			if x == '+':
				heapq.heappush(temp, ans[cnt])
				cnt += 1
			elif heapq.heappop(temp) != int(x.split(' ')[1]):
				print('NO')
				return 0
		print('YES')
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def naiveSolve():
	return

def main():
	n = int(input())
	add = [-1] * n
	latestAdd = 0
	addStack = []
	inputs = []
	for _ in range(2 * n):
		inputs.append(input())
		if inputs[-1][0] == '+':
			addStack.append(latestAdd)
			latestAdd += 1
		else:
			if len(addStack) == 0:
				print('NO')
				return
			v = int(inputs[-1].split()[1])
			add[addStack.pop()] = v
	import heapq
	addIdx = 0
	h = []
	for x in inputs:
		if x[0] == '+':
			heapq.heappush(h, add[addIdx])
			addIdx += 1
		else:
			v = int(x.split()[1])
			if v != heapq.heappop(h):
				print('NO')
				return
	print('YES')
	oneLineArrayPrint(add)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
from math import gcd, floor, ceil
for _abc in range(1):
	main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	A = []
	flag = True
	tmp = []
	res = []
	ops = []
	for i in range(2 * N):
		ops.append(getStr())
	ops.reverse()
	for i in range(2 * N):
		curr = ops[i]
		if curr[0] == '-':
			num = int(curr[2:])
			if not tmp or tmp[-1] > num:
				tmp.append(num)
			else:
				print('NO')
				return
		elif tmp:
			res.append(tmp.pop())
		else:
			print('NO')
			return
	print('YES')
	res = res[::-1]
	print(*res)
	return
solve()


import math
n = int(input())
s = []
for i in range(2 * n):
	a = input()
	if a[0] == '+':
		s.append(0)
	else:
		s.append(int(a[2:]))
st = []
f = 0
ans = []
mi = []
for i in range(len(s) - 1, -1, -1):
	if s[i] > 0:
		st.append(s[i])
		if mi == []:
			mi.append(s[i])
		elif s[i] < mi[-1]:
			mi.append(s[i])
		else:
			w = mi[-1]
			mi.append(w)
	elif st == []:
		f = 1
		break
	elif st[-1] == mi[-1]:
		p = st[-1]
		ans.append(p)
		st.pop()
		mi.pop()
	else:
		f = 1
		break
ans.reverse()
if f == 1:
	print('NO')
else:
	print('YES')
	print(*ans)


def solve():
	n = int(input())
	a = []
	for i in range(2 * n):
		s = input()
		if s[0] == '-':
			s = s.split()
			a.append([s[0], int(s[1])])
		else:
			a.append(s)
	st = []
	ans = []
	for i in a[::-1]:
		if i[0] == '+':
			if st:
				ans.append(st.pop())
			else:
				print('NO')
				return
		elif not st or st[-1] > i[1]:
			st.append(i[1])
		else:
			print('NO')
			return
	print('YES')
	print(*ans[::-1])

def main():
	t = 1
	for _ in range(t):
		solve()
main()


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	from heapq import heappush, heappop
	input = sys.stdin.readline
	N = int(input())
	ev = []
	for _ in range(2 * N):
		line = list(input().split())
		ev.append(line)
	ev.reverse()
	pq = []
	ans = []
	for line in ev:
		if len(line) == 1:
			if not pq:
				print('NO')
				exit()
			ans.append(heappop(pq))
		else:
			x = int(line[1])
			if pq:
				if x > pq[0]:
					print('NO')
					exit()
				else:
					heappush(pq, x)
			else:
				heappush(pq, x)
	ans.reverse()
	print('YES')
	print(*ans)
main()