static void Main(string[] args)
        {
            int cmdCount = int.Parse(Console.ReadLine());

            var stack = new StackMax <int>();

            int cmdCounter = 0;

            while (cmdCounter != cmdCount)
            {
                var cmd = Console.ReadLine();
                switch (cmd)
                {
                case "max":
                    Console.WriteLine(stack.Max());
                    break;

                case "pop":
                    stack.Pop();
                    break;

                default:
                    string[] push = cmd.Split(' ');
                    stack.Push(int.Parse(push[1]));
                    break;
                }
                cmdCounter++;
            }
            Console.ReadKey();
        }
        public static int[] TestAdapter(string[] input)
        {
            int cmdCount = int.Parse(input[0]);

            var        stack  = new StackMax <int>();
            List <int> Result = new List <int>();

            int cmdCounter = 0;

            while (cmdCounter != cmdCount)
            {
                var cmd = input[cmdCounter + 1];
                switch (cmd)
                {
                case "max":
                    Result.Add(stack.Max());
                    break;

                case "pop":
                    stack.Pop();
                    break;

                default:
                    string[] push = cmd.Split(' ');
                    stack.Push(int.Parse(push[1]));
                    break;
                }
                cmdCounter++;
            }
            return(Result.ToArray());
        }