Credits go to AMC Trivial and the AoPS wiki for making this possible.