#include <bits/stdc++.h>

using namespace std;

mt19937 mt(736);


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

		T x;
		unsigned y;
		nodeptr l, r;

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

		~node()
		{
			delete l;
			delete r;
		}
	};

	using nodeptr = typename node::nodeptr;

	static nodeptr make_node(const T &x)
	{
		return new node(x);
	}

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

		if (le->y < ri->y)
		{
			nodeptr ans = le;

			ans->r = merge(le->r, ri);

			return ans;
		}
		else
		{
			nodeptr ans = ri;

			ans->l = merge(le, ri->l);

			return ans;
		}
	}

	static pair<nodeptr, nodeptr> split(nodeptr h, const T &x)
	{
		if (h == nullptr)
			return {nullptr, nullptr};

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

			h->r = le;

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

			h->l = ri;

			return {le, h};
		}
	}

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

	nodeptr root = nullptr;

public:
	~treap()
	{
		delete root;
	}

	void insert(const T &x)
	{
		auto[le, ri]  = split(root, x);

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

	void erase(const T &x)
	{
		auto[le, ri]  = split(root, x);
		auto[lri, rri] = split(ri, x + 1);

		delete lri;

		root = merge(le, rri);
	}


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

	[[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.front()) << 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;
}
