Sort the amounts by remainder
Adding the small coin never changes the remainder, so each remainder class opens at one first value and stays open forever.
Adding the small coin never changes the remainder, so each remainder class opens at one first value and stays open forever.