Solved CodeChef November Challenge #2