Square Brackets--minor help needed

can u point out the mistake in my code.
link —https://ide.codingblocks.com/s/161562

for the first test case:
10
21 6
10 23 14 6 38 7
1 0
18 5
24 13 23 31 15
45 22
73 52 34 20 12 7 37 86 53 4 32 35 48 51 23 79 22 46 79 55 12 35
11 1
4
43 11
58 53 41 38 36 79 35 68 6 50 38
38 20
30 8 3 56 18 58 21 51 12 69 70 66 50 4 1 30 9 60 52 32
14 11
3 22 7 13 26 2 11 18 27 25 10
35 30
58 18 17 60 27 48 64 19 58 39 45 28 2 8 36 40 53 40 42 41 35 60 56 24 13 66 23 30 28 51
40 4
78 63 19 46

Your code is generating 0 for all test cases. So i guess either your answer is getting overflowed. Please check your modulous.
Also i suggest you to use ans = (ans%mod + x%mod)%mod instead of ans+=x; ans%=mod;

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.