https://www.hackerrank.com/challenges/correctness-invariant