
15 Cal.Rptr.3d 188 (2004)
119 Cal.App.4th 1279
The PEOPLE, Plaintiff and Respondent,
v.
David Lynn CAMPBELL, Defendant and Appellant.
No. A104284.
Court of Appeal, First District, Division Two.
June 29, 2004.
Review Denied September 29, 2004.[*]
*189 Carolyn Fershtman, Sebastopol, Under Appointment of the First District Court of Appeal, for Defendant and Appellant.
Bill Lockyer, Attorney General of the State of California, Robert R. Anderson, Chief Assistant Attorney General, Gerald A. Engler, Senior Assistant Attorney General, Martin S. Kaye, Supervising Deputy Attorney General, Nancy H. Tung, Deputy Attorney General, for Plaintiff and Respondent.
LAMBDEN, J.
Defendant had pleaded guilty to a crime covered by Proposition 36, the Substance Abuse and Crime Prevention Act, and received probation. At the hearing for his second drug-related violation of probation, defendant stipulated to an upper term sentence of three years as a condition of receiving outpatient treatment. Prior to the agreement, the trial court had determined that residential treatment was appropriate. *190 After receiving probation and outpatient treatment, defendant committed a non-drug related violation of his probation. The court revoked probation and sentenced him to the aggravated term of three years pursuant to the agreement. Defendant contends, among other things, that the trial court violated the terms of Penal Code section 1210.1,[1] by requiring him to stipulate to an upper term in return for receiving a specific type of treatment. We hold that the trial court improperly abdicated its authority by allowing defendant to choose his treatment in exchange for a particular sentence and that defendant is not estopped from now challenging the three-year sentence when the court failed to state its reasons for imposing the sentence but simply relied on the invalid agreement. Accordingly, we remand for resentencing.

BACKGROUND
An information filed June 12, 2002, charged defendant with being a felon in possession of ammunition (§ 12316, subd. (b)(1)), possession of methamphetamine (Health & Saf.Code, § 11377, subd. (a)), and misdemeanor possession of a hypodermic needle (Bus. & Prof.Code, § 4140). It further alleged that defendant had suffered two prior prison convictions (§ 667.5, subd. (b)).[2]
Defendant pleaded guilty to possession of methamphetamine. On December 20, the court pursuant to section 1210.1 suspended imposition of sentence and placed defendant on probation and ordered him to participate in drug treatment.
On January 23, 2003, the probation department reported that defendant had violated the terms of his probation when he submitted a urine sample that tested positive for methamphetamine on January 16. On January 24, the court revoked and reinstated him on probation.
Shortly thereafter, the probation officer again reported that defendant had violated his probation by submitting positive urine samples. Defendant failed to appear in court for his violation of probation hearing and, on February 21, 2003, the court summarily revoked his probation. On March 11, 2003, defendant admitted that he had violated probation by testing positive for methamphetamine. The court continued the case for sentencing. On April 9, the court ordered defendant to be interviewed for a residential treatment program.
At the sentencing hearing on July 3, 2003, the assessment officer reported that defendant was on the waiting list for residential treatment at Turning Point and that he "should be placed fairly quickly."[3] Defendant requested that the court consider outpatient treatment and stated the following: "Your Honor, could I say something? I mean, if I just  what I want, I've been here like four months. I know it's to my own doing. I got violated for the same thing I'm in 1210 court for. I'm not complaining about that, but if I could just have enough rope to hang myself to prove myself and to you I want this program, I can do this. I just want one chance, is all I'm asking for. I'll take whatever outpatient treatment they want to give me. It don't matter. I've got a clean and sober house to live at, a job right now, and I've got the *191 willingness and wantingness [sic] to do this. I just ask for like one chance. I was going to all my classes when I was out last time. I lived in a house that wasn't very clean and sober, so I relapsed. And that's my own fault, I realize that, but I just want one chance."
The court responded: "Well, I'll pass this ... so [defense counsel] can talk with [defendant], because if I give him this one chance it will be on the stipulation that he agrees that if he has any program violations, misses a test, it's dirty, miss anything else, he will stipulate to a three-year CDC commitment and waive any protection under [section] 1210."
After a break, counsel for defendant reported to the court: "... Despite my best advice, [defendant] does want to try to go to outpatient and do whatever he's told to do on outpatient. He understands that he'll be stipulating to a three-year state prison sentence, if he fails to do what he's supposed to do." The court then proceeded to ask defendant whether he had discussed with his attorney the ramifications of agreeing to a stipulated three-year sentence and whether he understood them. He responded affirmatively to both questions. The court explained: "All right. Let me make it clear to you ... that if you have any program violation, any probation violation, you have agreed that you have forfeited the right for any further sentencing protections of Penal Code section 1210. Do you agree to that, sir?" Defendant responded: "Yes, Your Honor." The court also asked defendant the following: "Do you also stipulate that this Court can sentence you forthwith, upon proof of those allegations, to a three-year CDC sentence? Do you agree to that ...?" Defendant responded that he did agree with that and had discussed the issue with his counsel. His counsel responded that he was satisfied that defendant understood his rights.
The court explained: "... I'm going to allow you to shoot yourself in the foot this way, so the Court is going to order that upon completion of your sentence  well, at this point he waives any further arraignment for judgment or sentence?" Defense counsel responded that he did, and the court continued: "For his violation the Court is going to reinstate him on probation...."
On August 27, 2003, defendant admitted that he had violated the terms of his probation by driving with a suspended license and without proof of insurance. Defendant stated: "Yeah, I do admit this violation. I did do it. When I made this deal I figured if Iif I didn't use drugs, I would have nothing to worry about. I put all my focus in trying to stay clean and took a couple of shortcuts in other areas of my life." Counsel for defendant stated that defendant had remained "clean and sober since he was last in custody."
The court responded that defendant may also be facing a robbery charge. As for the situation currently before the court, the court explained: "[Defendant] summed it up best ...: If I could just have enough rope to hang myself ... and the Court gave it to him. Actually we mixed our metaphors because when I sentenced you, I indicated that I was going to allow you to shoot yourself in the foot because you felt you could do it. Day after day I see folks in this courtroom who tell me that they can beat addiction because they've got it all figured out, and treatment folks tell me they don't think they have it figured out but every once in a while I let somebody go ahead and try to prove it to me or fall flat on their face. And you shot yourself in the foot and you used a bazooka to do it."
The court denied probation and committed defendant to prison for the stipulated term of three years.
*192 Defendant filed a timely notice of appeal.

DISCUSSION
It is undisputed that defendant's original crime and his second violation of probation were drug offenses, both covered by Proposition 36. Defendant contends that the court erred in requiring him to stipulate to an upper term sentence in return for outpatient treatment following his second drug-related violation of probation. Such an agreement, defendant asserts, contravenes the mandates of Proposition 36. The People respond that the court had the authority to offer defendant outpatient treatment in return for agreeing to the upper term sentence and, even if it did not, defendant received the benefit of the bargain and cannot now complain that the court lacked jurisdiction to make it. We therefore consider whether the court had the authority to accept such an agreement from defendant and, if not, defendant is estopped from challenging the three-year sentence.

I. Bargains for Specific Types of Treatment and Proposition 36


A. The Purpose and Mandates of Proposition 36

In People v. Floyd (2003) 31 Cal.4th 179, 1 Cal.Rptr.3d 885, 72 P.3d 820, the California Supreme Court explained that California voters passed Proposition 36, the Substance Abuse and Crime Prevention Act (Act), on November 7, 2000, and "amended state law to require that certain adult drug offenders receive probation, conditioned on participation in and completion of an appropriate drug treatment program, instead of receiving a prison term or probation without drug treatment." (Floyd, supra, at p. 183, 1 Cal.Rptr.3d 885, 72 P.3d 820.) The Act, codified by sections 1210, 1210.1, and 3063.1 and by division 10.8 (commencing with section 11999.4) of the Health and Safety Code, took effect on July 1, 2001. (People v. Murillo (2002) 102 Cal.App.4th 1414, 1417, 126 Cal.Rptr.2d 358.)
"The manifest purpose behind Proposition 36 was to divert into treatment those persons whose only offenses were nonviolent drug possession offenses. Proposition 36 explained its intent, among other things, to (1) `divert from incarceration into community-based substance abuse treatment programs nonviolent defendants, probationers and parolees charged with simple drug possession or drug use offenses'; and (2) `enhance public safety by reducing drug-related crime and preserving jails and prison cells for serious and violent offenders, and to improve public health by reducing drug abuse and drug dependence through proven and effective drug treatment strategies.'" (People v. Goldberg (2003) 105 Cal.App.4th 1202, 1208, 130 Cal.Rptr.2d 192.)
Section 1210.1 provides in relevant part: "(a) Notwithstanding any other provision of law, and except as provided in subdivision (b), any person convicted of a nonviolent drug possession offense shall receive probation. As a condition of probation the court shall require participation in and completion of an appropriate drug treatment program.... A court may not impose incarceration as an additional condition of probation. Aside from the limitations imposed in this subdivision, the trial court is not otherwise limited in the type of probation conditions it may impose. Probation shall be imposed by suspending the imposition of sentence."
With regard to a second drug-related probation violation, section 1210.1, subdivision (e)(3)(B) reads in relevant part: "If a defendant receives probation under subdivision (a), and for the second time violates *193 that probation either by committing a nonviolent drug possession offense, or a misdemeanor for simple possession or use of drugs or drug paraphernalia, being present where drugs are used, or failure to register as a drug offender, ..., or by violating a drug-related condition of probation, and the state moves for a second time to revoke probation, the court shall conduct a hearing to determine whether probation shall be revoked. The trial court shall revoke probation if the alleged probation violation is proved and the state proves by a preponderance of the evidence either that the defendant poses a danger to the safety of others or is unamenable to drug treatment. In determining whether a defendant is unamenable to drug treatment, the court may consider, to the extent relevant, whether the defendant (i) has committed a serious violation of rules at the drug treatment program, (ii) has repeatedly committed violations of program rules that inhibit the defendant's ability to function in the program, or (iii) has continually refused to participate in the program or asked to be removed from the program. If the court does not revoke probation, it may intensify or alter the drug treatment plan...."

B. Bargaining for Specific Types of Treatment

A defendant who is on probation pursuant to Proposition 36 can only have that probation revoked in accordance with the terms of the statutory scheme. (In re Mehdizadeh (2003) 105 Cal.App.4th 995, 1006, 130 Cal.Rptr.2d 98; see also People v. Davis (2003) 104 Cal.App.4th 1443, 1448, 129 Cal.Rptr.2d 48 ["the conditions under which the court can revoke probation, and the sanctions the court may impose, are limited as outlined in the provisions of ... section 1210"].) In the case before us, the second time defendant violated his probation it was a drug-related offense and therefore the court had to comply with the requirements of section 1210.1, subdivision (e)(3)(B). Under the provisions of section 1210.1, the trial court could have "intensif[ied]" defendant's treatment program, by requiring additional vocational training, education, drug testing, or counseling. (§ 1210.1, subds.(e)(3)(B) & (E), (f).) The court could have also informed defendant that if he failed to comply with the terms of his drug treatment or with the terms of probation, the court intended to impose a state prison sentence. The court clearly had the authority to revoke probation and sentence defendant if he committed a non-drug-related probation violation. (§ 1210.1, subd. (e)(2).)[4]
The People acknowledge that the statute requires the court to impose probation since revocation of probation is only authorized if the People prove defendant refused treatment or was unamenable to it (§ 1210.1, subd. (e)(3)(B)), and the People presented no evidence of this. However, they argue that the court did not violate the statute because it did not condition the order of probation on the acceptance of a three-year sentence. Rather, they assert that the stipulation was in return for receiving outpatient rather than residential treatment and nothing in the statute prohibits the court from accepting defendant's stipulated sentence.
*194 The question before us is whether the statute permits the trial court to provide the treatment desired by the defendant on the condition that the defendant accept a particular sentence if probation is later violated. In considering this issue we look to the express language of the statute. The statute specifies that when a person commits a drug crime the "court shall require participation in and completion of an appropriate drug treatment program...." (§ 1201.1, subd. (a).) If the defendant commits a drug related violation of probation and the court does not revoke probation, the court "may intensify or alter the drug treatment plan." (Id., subd. (e)(3)(B).) It is the court, not the defendant, that is to determine the "appropriate" drug treatment program and is to decide whether to "alter" or "intensify" the program. This statute does not allow for the defendant  who has a drug abusing history  to determine the "appropriate" treatment. Accordingly, permitting the drug abusing defendant to select the treatment to be provided on the condition that the defendant accepts a particular sentence should the defendant subsequently violate probation is clearly contrary to the mandates of the statute and is unauthorized.[5]

II. Waiver and Agreements Contrary to the Mandates of Proposition 36

The People argue that even if the court did not have the authority to condition the type of treatment on acceptance of a three-year sentence, defendant has waived any protections of Proposition 36 by entering into the agreement and is estopped from arguing the invalidity of this sentence on appeal. (People v. Couch (1996) 48 Cal.App.4th 1053, 1057, 56 Cal.Rptr.2d 220 ["`Where a court is merely acting in excess of its jurisdiction, the defendant who agrees to such actions may be estopped later from challenging the court's actions on jurisdictional grounds.'"].) Defendants may waive statutory rights that are beneficial to them. (Cowan v. Superior Court (1996) 14 Cal.4th 367, 371, 58 Cal.Rptr.2d 458, 926 P.2d 438.)
"As the United States Supreme Court has observed, `"[t]he most basic rights of criminal defendants are ... subject to waiver.'" [Citation.]" (People v. Johnson (2002) 28 Cal.4th 1050, 1055, 123 Cal.Rptr.2d 700, 51 P.3d 913.) "Generally, permitting waiver `"is consistent with the solicitude shown by modern jurisprudence to the defendant's prerogative to waive the most crucial of rights." [Citation.]' [Citation.] A defendant may waive a right that exists for his or her own benefit, where such waiver is not against public policy." (People v. Farnam (2002) 28 Cal.4th 107, 146, 121 Cal.Rptr.2d 106, 47 P.3d 988.) A defendant may waive a right accorded by statute so long as the statute does not expressly preclude waiver. (People v. Jackson (1996) 13 Cal.4th 1164, 1209-1211, 56 Cal.Rptr.2d 49, 920 P.2d 1254.)
The People argue that no statute precludes waiver and the bargain struck in this case resembles that made in a plea bargain. (See People v. Ellis (1987) 195 Cal.App.3d 334, 343, 240 Cal.Rptr. 708, superseded by statute on another issue.) Here, defendant wanted to receive outpatient treatment rather than be placed in the residential program where the court had ordered him placed. The People argue that defendant represented to the court that he would take any outpatient program and that he just wanted "one more chance." The stipulation, according to the People, allowed defendant the freedom *195 of an outpatient program rather than the residential treatment program favored and already selected by the court and the assessment officer. Having accepted the benefit of the bargain, the People maintain that defendant cannot now claim that the court did not have the jurisdiction to enter into such a bargain.
The People also argue that public policy is not thwarted by enforcing the stipulated sentence. By agreeing to defendant's request, conditioned on the additional incentive of a three-year prison sentence if defendant's efforts failed, the People argue that the stipulated sentence provided a motivating factor for defendant to adhere to the terms of his probation.
This is not a situation where the defendant has opted out of the benefits of Proposition 36 by refusing drug treatment or by agreeing that Proposition 36 does not apply. Rather, this is a situation where all the parties agree Proposition 36 applies. The court, ignoring the mandate of Proposition 36, agreed to let defendant receive outpatient treatment despite its earlier determination that he should receive residential treatment at Turning Point. Thus, the purpose of the statute  to rehabilitate  and its mandate  that the court require participation in and completion of an "appropriate" drug treatment program (§ 1201.1, subd. (a), see also subd. (e)(3)(B))  are frustrated if the court, against its better judgment and while acknowledging that it was permitting defendant "to shoot [himself] in the foot," abandons its responsibility and allows the defendant to bargain for treatment that the court expressly expected to fail.
We disagree with the People that public policy supports the enforcement of this bargain. Section 1210.1 is a narrowly tailored statutory scheme that requires the trial court to treat those convicted of nonviolent drug possession offenses "as a separate class subject only to the special probation rules" expressly included in section 1210.1. (In re Mehdizadeh, supra, at p. 1005, 130 Cal.Rptr.2d 98.) Trial courts are required to follow the procedural schema set forth in section 1210.1's "detailed system of escalating sanctions for drug-related violations of probation." (Ibid.) The trial court does not retain "general discretion to revoke probation according to their views of `the interests of justice.'" (Id. at p. 1006, 130 Cal.Rptr.2d 98.)
More significantly, "`An accused may waive any rights in which the public does not have an interest and if waiver of the right is not against public policy.' [Citation.]" (Cowan v. Superior Court, supra, 14 Cal.4th at p. 371, 58 Cal.Rptr.2d 458, 926 P.2d 438.) The stated purpose of Proposition 36 is "`[t]o halt the wasteful expenditure of hundreds of millions of dollars each year on the incarceration  and reincarceration  of nonviolent drug users who would be better served by community-based treatment....'" (Historical and Statutory Notes, 51 West's Ann. Pen.Code (2004 ed.) foll. § 1210, p. 640.) To effectuate the purpose, Proposition 36 anticipates initial failures at drug rehabilitation and allows offenders multiple chances at probation before a court is permitted to impose a prison sentence. As already stated, the purpose of the statute is to try to rehabilitate; the court has to be the one to decide what package of probation conditions is most likely to succeed. The public's interest is not served when the court conditions a maximum prison term on the basis of providing the defendant with the treatment that the defendant desires  not the treatment that the court deems is most likely to succeed. Indeed, such agreements are clearly contrary to the public's interest because they enhance the likelihood *196 of failure in the drug treatment program and increase the likelihood of the "wasteful expenditure" of money on the incarceration of a nonviolent drug user.
Thus, we hold that defendant is not estopped from challenging his sentence and the court erred when it simply sentenced him to the stipulated term without explaining its reasons for the sentence. We reverse the sentence and remand for the trial court to determine the proper sentence. We note that the court may, in exercising its discretion, determine that the upper, middle, or lower term is the appropriate sentence or it may determine that probation with treatment in a residential program is proper. If the court imposes a state prison sentence, it must "[h]ear evidence in aggravation and mitigation, and determine, pursuant to section 1170(b), whether to impose the upper, middle or lower term; and set forth on the record the facts and reasons for imposing the upper term." (Cal. Rules of Court, rule 4.433(c)(1).)

DISPOSITION
The judgment is reversed as to the sentence and remanded for resentencing and further proceedings consistent with this opinion. In all other respects, the judgment is affirmed.
We concur: KLINE, P.J., and RUVOLO, J.
NOTES
[*]   George, C.J., did not participate therein. Kennard, J., dissented.
[1]  All further unspecified code sections refer to the Penal Code.
[2]  The record does not contain the underlying facts regarding these crimes, and they are not necessary to any determination of the issues raised by this appeal.
[3]  Defendant was on a parole hold and the court indicated that his parole hold would be completed on July 5.
[4]  Section 1210.1, subdivision (e)(2) provides in relevant part: "[¶] If a defendant receives probation under subdivision (a), and violates that probation either by being arrested for an offense that is not a nonviolent drug possession offense, or by violating a non-drug-related condition of probation, and the state moves to revoke probation, the court shall conduct a hearing to determine whether probation shall be revoked. The court may modify or revoke probation if the alleged violation is proved...."
[5]  In this case, the court and assessment officer had decided earlier that residential treatment  not outpatient treatment  was the "appropriate" treatment.
