Help in recursive question..need clarity and where to practice more like these..?

https://codeforces.com/contest/1385/problem/D