static void Main(string[] args) { using (reader = File.OpenText("input.txt")) using (writer = new StreamWriter(File.Create("output.txt"))) { int m = reader.ReadInt(); CustomQueue <int> queue = new CustomQueue <int>(m + 1); while (m > 0) { var cmd = reader.ReadToken(); int value; switch (cmd) { case "+": int number = reader.ReadInt(); queue.Enqueue(number); break; case "-": value = queue.Dequeue(); break; case "?": value = queue.Min(); writer.WriteLine(value); break; } m--; } } }