Black box#3358

Black box

1 second
122.174 megabytes
Very easy

Sheets with numbers are placed into a black box. Each sheet contains exactly one integer. From time to time, some sheets disappear from the box.

After each event (adding or removing a sheet), you must print the number that appears most frequently among all the remaining sheets in the box. If there are multiple such numbers, print the smallest one.

Input

The first line contains the number of events (1 \le n \le 2 \cdot 10^5). Each of the following lines describes one event:

  • — a sheet with number (1 \le x \le 10^6) is added to the box;

  • — a sheet with number disappears from the box (it is guaranteed that there is at least one such sheet in the box).

Output

Print exactly lines — one per event. Each line should contain a single number — the answer to the problem.

If the box is empty after an event, print .

Examples

Example 1

Loading
Loading