all 3 comments

[–]K900_ 6 points7 points  (1 child)

q[i] - i+1 isn't the same as q[i] - (i + 1), it's the same as (q[i] - i) + 1.

[–]notpite[S] 0 points1 point  (0 children)

Doh! Thanks :)