Need Explanation for WCEPROB7 (CARN2021)

Links: Problem | Contest

I am unable to figure out how to find total number of ways to distribute candies among groups of variable size. Can someone please explain how to approach this problem?