CSES problem

Can some one help me in this problem in cses
CSES - Counting Reorders
Many thanks !!!