Help me in this problem

please help me to solve this problem
https://codeforces.com/group/iFnrXVM9hB/contest/263609/problem/E