class Stack:
    def __init__(self):
        self.A = []
        self.B = []
    def push(self, val):
        self.A.append(val)
        if not self.B or self.B[-1] >= val:
            self.B.append(val)
    def pop(self):
        if self.B and self.A.pop() == self.B[-1]:
            self.B.pop()
    def getMin(self):
        if self.B:
            return self.B[-1]
        return -1

s = Stack()
n = int(input())
for _ in range(n):
    l = input().split()
    if l[0] == 'push':
        s.push(int(l[1]))
    elif l[0] == 'pop':
        s.pop()
    elif l[0] == 'getMin':
        print(s.getMin())