add loop invariant hackerrank problem