how to find loop invariant - Search