Though it won't matter for the square matrix, we should use ``for i in range(dist.shape[0])`` to make the code more clear.