Didn't work because a is being set to 0 at the end of the loop. But thanks.