#include <bits/stdc++.h>

using namespace std;

mt19937 mt(736);


template<class T>
class treap
{
	struct node
	{
		using nodeptr = unique_ptr<node>;

		const T x;
		const unsigned y;
		nodeptr l, r;
		size_t sz;

		explicit node(const T &x = T{}) : x(x), y(mt()), l(nullptr), r(nullptr), sz(1)
		{}
	};

	using nodeptr = typename node::nodeptr;

	static void upd(const nodeptr &h)
	{
		if (h != nullptr)
			h->sz = get_size(h->l) + 1 + get_size(h->r);
	}

	static size_t get_size(const nodeptr &h)
	{
		return h == nullptr ? 0 : h->sz;
	}

	static nodeptr make_node(const T &x)
	{
		return make_unique<node>(x);
	}

	static nodeptr merge(nodeptr &&le, nodeptr &&ri)
	{
		if (le == nullptr)
			return move(ri);
		if (ri == nullptr)
			return move(le);

		if (le->y < ri->y)
		{
			nodeptr ans = merge(move(le->r), move(ri));
			le->r = move(ans);

			upd(le);

			return move(le);
		}
		else
		{
			nodeptr ans = merge(move(le), move(ri->l));
			ri->l = move(ans);

			upd(ri);

			return move(ri);
		}
	}

	static pair<nodeptr, nodeptr> split(nodeptr &&h, const function<bool(const nodeptr &)> &fn)
	{
		if (h == nullptr)
			return {nullptr, nullptr};

		if (fn(h))
		{
			auto[le, ri] = split(move(h->r), fn); // structured binding

			h->r = move(le);

			upd(h);

			return {move(h), move(ri)};
		}
		else
		{
			auto[le, ri] = split(move(h->l), fn);

			h->l = move(ri);

			upd(h);

			return {move(le), move(h)};
		}
	}

	static const T &front(const nodeptr &h)
	{
		if (h->l == nullptr)
			return h->x;
		return front(h->l);
	}

	nodeptr root = nullptr;

public:
	void insert(const T &x)
	{
		auto cmp_less = [&x](const nodeptr &h) -> bool
		{
			return h->x < x;
		};

		auto[le, ri] = split(move(root), cmp_less);

		root = merge(move(le), merge(make_node(x), move(ri)));
	}

	void erase(const T &x)
	{
		auto cmp_less = [&x](const nodeptr &h) -> bool
		{
			return h->x < x;
		};
		auto cmp_leq = [&x](const nodeptr &h) -> bool
		{
			return h->x <= x;
		};

		auto[le, ri] = split(move(root), cmp_less);
		auto[lri, rri] = split(move(ri), cmp_leq);

		root = merge(move(le), move(rri));
	}


	const T &nth_element(size_t n)
	{
		auto cmp = [&n](const nodeptr &h)
		{
			if (auto sz = get_size(h->l); sz < n)
			{
				n -= sz + 1;

				return true;
			}
			else
				return false;
		};

		auto[le, ri] = split(move(root), cmp);

		if (ri == nullptr)
			throw out_of_range("");

		const auto &ans = front(ri);

		root = merge(move(le), move(ri));

		return ans;
	}


	[[nodiscard]] bool empty() const
	{
		return root == nullptr;
	}


	[[nodiscard]] auto size() const
	{
		return get_size(root);
	}

	[[nodiscard]] const T &front() const
	{
		if (empty())
			throw out_of_range("front of an empty treap");

		return front(root);
	}
};


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int q;

	cin >> q;

	treap<int> tr;

	for (int i = 0; i < q; i++)
	{
		char ch;
		int x;

		cin >> ch >> x;

		if (ch == '+')
			tr.insert(x);
		if (ch == '-')
			tr.erase(x);

		cout << (tr.empty() ? -1 : tr.nth_element(0)) << endl;
	}
}


void stress(istream &cin = std::cin, ostream &cout = std::cout)
{
	int q;

	cin >> q;

	multiset<int> tr;

	for (int i = 0; i < q; i++)
	{
		char ch;
		int x;

		cin >> ch >> x;

		if (ch == '+')
			tr.insert(x);
		if (ch == '-')
			tr.erase(x);

		cout << (tr.empty() ? -1 : *tr.begin()) << endl;
	}
}


void gen(ostream &cout = std::cout)
{
	const int q = 10;

	cout << q << endl;

	uniform_int_distribution<int> uid(0, 10), type(0, 1);

	for (int j = 0; j < q; j++)
		cout << (type(mt) ? '+' : '-') << ' ' << uid(mt) << endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	cout << fixed;

#ifdef LOCAL
	auto st = chrono::steady_clock::now();

	ifstream fin("../input.txt");

	do
	{
		solve(fin);

		cout << "===" << endl;

		string str;
		while (getline(fin, str) && str != string(max(1, (int) str.size()), '='));
	} while (fin);

	for (int cnt = 0; cnt < (int) 1e4; cnt++)
	{
		stringstream ss, in1, in2, out1, out2;

		gen(ss);

		in1 << ss.str();
		in2 << ss.str();

		solve(in1, out1);
		stress(in2, out2);

		if (out1.str() != out2.str())
		{
			cout << "fail: " << cnt << endl;
			cout << ss.str();
			cout << "solve" << endl;
			cout << out1.str();
			cout << "stress" << endl;
			cout << out2.str();

			break;
		}
		else if (cnt % 100 == 0)
			cout << "ok: " << cnt << endl;
	}

	cout << setprecision((int) floor(log10(chrono::steady_clock::duration::period::den)));
	cout << "clock: " << chrono::duration<double>(chrono::steady_clock::now() - st).count() << endl;
#else
	solve();
#endif

	return 0;
}
