Can someone please provide an editorial for the question A6?

I have no idea how to solve this question. codechef.com/problems/A6. I can’t find the solution anywhere and haven’t got a reply from any forum for it till now
@admin, help

//