Under construction

Still being built. Things may change

Album of Numbers

Time limit3sMemory limit128 MB

Summary
After each insertion or deletion in a multiset, print the arithmetic mean of the minima over all distinct nonempty sub-multisets of the album.
Level

Medium7 of 10

Topics
Combinatorics, Segment tree, Math
Solved
No attempts yet

Statement

Johnny is a collector of numbers. He has a large album with them, which he keeps updating by inserting new numbers and deleting old ones.

This album is Johnny's most prized treasure, so he wants to be sure that no one will ever replace his numbers with different ones. He therefore maintains a checksum for the album, determined as follows. He considers all distinct nonempty subsets of the numbers in the album, finds the minimum of each subset, and then calculates the arithmetic mean of these minima.

Because a number may appear multiple times in the album, the subsets are multisets: each number may appear in a subset multiple times, but no more than it appears in the whole album. Two multisets are equal if and only if every number has the same multiplicity in both. For instance, the album {1,2,2,5}\{1, 2, 2, 5\} has the following 11 distinct subsets: {1}\{1\}, {1,2}\{1, 2\}, {1,2,2}\{1, 2, 2\}, {1,2,2,5}\{1, 2, 2, 5\}, {1,2,5}\{1, 2, 5\}, {1,5}\{1, 5\}, {2}\{2\}, {2,2}\{2, 2\}, {2,2,5}\{2, 2, 5\}, {2,5}\{2, 5\}, and {5}\{5\}.

The album changes often, which makes maintaining the checksum by hand tedious. Write a program that reads the number of updates and their descriptions, determines the checksum after each operation, and prints the checksums.

Input

The first line contains a single positive integer nn (1≤n≤250 0001 \le n \le 250\,000), the number of updates. Each of the next nn lines contains a sign, either + or -, a single space, and a number aia_i (1≤ai≤1 000 000 0001 \le a_i \le 1\,000\,000\,000). A + inserts aia_i into the album, and a - removes one occurrence of aia_i from the album.

The album is initially empty. It is always nonempty after an operation, and only numbers present in the album are ever deleted.

Output

Print exactly nn lines. The ii-th line contains the checksum after the ii-th update. An answer is accepted if the absolute or relative error of each checksum does not exceed 10−610^{-6}.

Hint

In the first sample, after all the insertions, the album contains {1,2,2,5}\{1, 2, 2, 5\}. At that point Johnny considers the 11 subsets listed above. Their minima are 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 5. Hence the checksum is 1911≈1.727272727\frac{19}{11}\approx 1.727272727.

Examples2

  1. Example 1

    Input
    6
    + 10
    + 13
    - 10
    + 7
    + 2
    + 5
    
    Expected output
    10.000000000
    11.000000000
    13.000000000
    9.000000000
    5.000000000
    4.200000000
    
  2. Example 2

    Input
    4
    + 1
    + 2
    + 2
    + 5
    
    Expected output
    1.000000000
    1.333333333
    1.400000000
    1.727272727