← Home
package main

import (
	"bufio"
	"math/bits"
	"os"
	"strconv"
)

type MinHeap []int

func (h *MinHeap) Push(val int) {
	*h = append(*h, val)
	h.up(len(*h) - 1)
}

func (h *MinHeap) Pop() {
	n := len(*h) - 1
	(*h)[0], (*h)[n] = (*h)[n], (*h)[0]
	*h = (*h)[:n]
	if n > 0 {
		h.down(0)
	}
}

func (h *MinHeap) up(j int) {
	for {
		i := (j - 1) / 2
		if i == j || (*h)[j] >= (*h)[i] {
			break
		}
		(*h)[i], (*h)[j] = (*h)[j], (*h)[i]
		j = i
	}
}

func (h *MinHeap) down(i int) {
	n := len(*h)
	for {
		left := 2*i + 1
		if left >= n {
			break
		}
		j := left
		if right := left + 1; right < n && (*h)[right] < (*h)[left] {
			j = right
		}
		if (*h)[i] <= (*h)[j] {
			break
		}
		(*h)[i], (*h)[j] = (*h)[j], (*h)[i]
		i = j
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	buf := make([]byte, 1024*1024)
	scanner.Buffer(buf, 1024*1024)

	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	scanner.Scan()
	q := 0
	for _, b := range scanner.Bytes() {
		q = q*10 + int(b-'0')
	}

	heaps := make([]MinHeap, 30)
	sumK := make([]int, 30)
	count := make(map[int]int)
	total := 0

	for i := 0; i < q; i++ {
		scanner.Scan()
		isAdd := scanner.Bytes()[0] == '+'

		scanner.Scan()
		x := 0
		for _, b := range scanner.Bytes() {
			x = x*10 + int(b-'0')
		}

		k := bits.Len32(uint32(x)) - 1

		if isAdd {
			if count[x] == 0 {
				heaps[k].Push(x)
			}
			count[x]++
			sumK[k] += x
			total++
		} else {
			count[x]--
			sumK[k] -= x
			total--
		}

		if total == 0 {
			writer.WriteString("0\n")
		} else {
			ans := total - 1
			S := 0
			for j := 0; j < 30; j++ {
				for len(heaps[j]) > 0 && count[heaps[j][0]] == 0 {
					heaps[j].Pop()
				}
				if len(heaps[j]) > 0 {
					m := heaps[j][0]
					if S > 0 && 2*S < m {
						ans--
					}
					S += sumK[j]
				}
			}
			writer.WriteString(strconv.Itoa(ans))
			writer.WriteByte('\n')
		}
	}
}