Practice your stack data structure. You will be given a series of tasks of push, pop, peek operations to perform on a stack. You need to print the sum of the final stack.
First line contains Q, the number of queries.
The next Q lines each contain a query. PUSH queries are accompanied by a positive number N.
Print the topmost element for every 'PEEK' query, each in a newline.
Also, print the sum of the remaining elements of the stack in the end in a newline.
1 ≤ Q ≤ 50
1 ≤ N ≤ 1000
It is guaranteed that there would be no query of pop or peek operation on an empty stack.