Naive algorithm.