Google Singapore Intern Online Coding Contest

I encountered the following question asked in Google Singapore Online Coding Contest. I was not able to solve it. Can someone solve this and explain me the solution.https://codeforces.com/predownloaded/47/90/4790147d5c61f4b2d27f0c3d7c2e1bfb76240b8c.png