Modulo sum implementation.