I am not sure what is going wrong in my code

I have applied the same approach as suggested in hint video, still not passed all the test cases.
My code link is https://pastebin.com/RBABSy8M,
please help, thanks for your support.

pre_sum += ((v[i]+n)%n);

there might be cases when the prefix sum becomes negative so u need to add n to the prefix_sum each time and then take mod n so that that index been refered to is non negative