Count inversion algorithm added.