# Negative numbers in RRMATRIX

I read the whole problem 3-4 times but unable to understand that why there is an interference of negative numbers during calculations.

Also i didn’t understand the output details

Output single integer — the answer for the problem modulo 107 + 7, i.e the smallest non-negative integer number r that answer - r is divisible by 107 + 7.

Can anyone please explain me, i think so i have not understood the problem or i guess i am missing some important line mentioned in problem.

In the constraints there is a line

0 ≤ |Ai, j| ≤ 100

This means that the elements in the array can be negative numbers also.

i.e., -100 <= A(i,j) <= +100

That why there is an interference of negative numbers during calculations.

Now to answer your second doubt, as there can be negative elements, their multiplications can be negative.

So A(i,j)*A(x,y) can be both negative or positive (maybe even zero).

You have to output the resultant sum in a modulo 10^7 +7 but as there exists negative numbers thee result of modulo can also be negative. You need to show the non-negative part of it.

That means if resultant sum is -12 and MOD is 5 then, -12 % 5 = -2, -2+5=3, this is the non negative ans.

Now " the smallest non-negative integer number r that answer - r is divisible by 107 + 7. " means in our example,

ans=3; 3-r => 3-(-12)=15 and 15%5 = 0.

Hope this helps.

1 Like

okay thanks that’s what i was missing, absolute values…!!

Thanks…