Optimal Orchestration of Rewards and Punishments in Rank-Order Contests