Yo`nalishlar
Hozirda online

Statistika

Masalalar soni: 909

Foydalanuvchilar soni: 8824

Jo'natishlar soni: 714622

Muhokama yozuvlari: 4541

Yangiliklar soni: 98

Yangiliklar izohlari: 1177


So'ngi izohlar

733. Minimum in the Stack
Vaqt limiti: 2 sekund
Xotira limiti: 64 MB

The input to a program is a set of operations with a stack. Each operation is either an addition or removal of an item to or from the stack. After each operation find the smallest number in a stack. Summarize all the resulting numbers and get the answer. If after any operation the stack is empty, then add nothing to the answer. If it is impossible to remove an item because the stack is empty, then do nothing.

    Input

In the first line given a number m – the numbers of operations(1≤n≤105). Next n lines contain the type operation. It may push or pop. If it is push then given a number wich adding to stack. The numbers are in range from 1 to 109.

   Output

   Print one number - the result.

   Samples

Input

Output

1

9

push 5

push 3

pop

pop

pop

push 10

push 11

push 1

pop

44

2

1

pop

0

 

Tayyorladi: Azat Yusupov
Text from: e-olimp.com
Mening urinishlarim(0) Muhokama (2) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(22) Barcha urinishlar(62)