Help me in solving KOL1506 problem

My issue

Problem Link: KOL1506 Problem - CodeChef