Length of the union#709

Length of the union

1 second
128 megabytes
Very easy

Consider a set of segments on a line, each with integer endpoints. Initially, the set is empty. You can add segments to the set or remove segments from it. After each operation—whether it is adding or removing a segment—you need to output the total length of the union of all segments currently in the set.

Input

The first line contains an integer 1 \leq n \leq 100\ 000 — the total number of operations. Each of the following lines describes an operation. The first character is + if the operation is to add a segment, or - if the operation is to remove a segment. After the character, there are two integers separated by a space — the left and right endpoints of the segment. The coordinates of the endpoints do not exceed in absolute value. It is guaranteed that only those segments that were previously added to the set can be removed. Identical segments can be added multiple times; each instance is considered a separate segment.

Output

Output exactly numbers, one per line — the total length of the union of all segments in the set after each of the operations, whether it is an addition or a removal.

Examples

Example 1

Loading
Loading