Try insertion sort and properly add congruences