Miss Amina is organizing an excursion for primary school students to The Lake of Ichkeul, well-known locally as Bouhayret Echkel. She's managing the payment queue where students come to settle their trip fees.
The payment system works as follows:
Students may also leave the queue in groups from either end (called away for verification, already processed, etc.).
Miss Amina frequently needs to calculate the net payment for specific sections of the queue. This is crucial for:
Your task is to help Miss Amina by simulating the queue operations and answering her payment queries.
The first line contains a single integer $$$Q (2 \leq Q \leq 10^6)$$$ — the number of operations.
Each of the next $$$Q$$$ lines contains one of the following operations:
It is guaranteed that:
For each operation of type $$$5$$$, output a single integer — the net payment (sum of payment balances) in dinars for the specified range.
72 -501 1001 -2002 1505 1 23 25 0 1
50 100
The queue is $$$0$$$-indexed from the front. So if the queue is $$$[a, b, c, d]$$$, then: