All test cases are not passing

Can you tell me what’s wrong with my code
Here is the link – https://ide.codingblocks.com/s/341244

Modified code

  1. define size of freq array only n+1
    2)sum = (sum%n+n)%n; also take mod with n

it is passing all testcases execpt one
i am looking into that
may be the testcase problem
i will inform you about updates

constraints are very large
so make m of the type long long int also
long long int m = freq[i];

Final Modified code

it is passing all testcase you can check
if you have any further doubt on this fell free to ask

if doubt is resolved
don’t forgot to mark it as resolved

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.