In this article we derive the sentence — choosing among the sanctions of prison, parole, and probation — that achieves a target level of deterrence at least cost. Potential offenders discount the future disutility of sanctions and the state discounts the future costs of sanctions. Prison has higher disutility and higher cost per unit time than parole and probation, but the cost of prison per unit of disutility can be lower or higher than the cost of parole and probation per unit of disutility. The optimal order of sanctions depends on the relative discount rates of potential offenders and the state, and the optimal duration of sanctions depends on the relative costs per unit of disutility among the sanctions and on the target level of deterrence. We focus on the case in which potential offenders discount the disutility of sanctions at a higher rate than the state discounts the costs of sanctions. In this case, if prison is more cost-effective than parole and probation — that is, has a lower cost per unit of disutility — prison should be used exclusively. If prison is less cost-effective than parole and probation, probation should be used if the deterrence target is low enough, and prison followed by parole should be used if the deterrence target is relatively high. Notably, it may be optimal to employ a prison term even if prison is less cost-effective than parole and probation and even if prison is not needed to achieve the target level of deterrence, because of what we refer to as the front-loading advantage of imprisonment.