using System.Collections.Generic;
public class MaximumElement
public static void Main()
int n = int.Parse(Console.ReadLine());
Stack<int> stack = new Stack<int>();
int biggestNum = int.MinValue;
for (int i = 0; i < n; i++)
string[] command = Console.ReadLine().Split();
if (command[0].Equals("1"))
int num = int.Parse(command[1]);
else if (command[0].Equals("2"))
biggestNum = stack.Max();
else if (command[0].Equals("3"))
Console.WriteLine(biggestNum);