
    The People of the State of New York, Respondent, v Raymond Gray, Appellant.
    [856 NYS2d 887]
   Appeal by the defendant from a judgment of the County Court, Suffolk County (Gazzillo, J.), rendered January 18, 2007, convicting him of criminal possession of a controlled substance in the third degree, upon his plea of guilty, and imposing sentence.

Ordered that the judgment is affirmed.

The defendant contends that the sentencing court failed to exercise its discretionary powers when imposing sentence, and thereby imposed the sentence illegally. This contention is without merit (see People v Farrar, 52 NY2d 302, 308 [1981]). The sentencing court ultimately exercised its discretion in sentencing the defendant, even though the sentence imposed was pursuant to a plea agreement (see People v Daniel D., 123 AD2d 782 [1986]).

The defendant’s “valid and unrestricted written waiver of the right to appeal, as part of his plea agreement, precludes appellate review of his claim that the sentence imposed was excessive” (People v Morrow, 48 AD3d 704, 705 [2008]; People v Lopez, 6 NY3d 248, 255 [2006]; see also People v Cumba, 32 AD3d 444, 445 [2006]). Mastro, J.E, Rivera, Angiolillo and McCarthy, JJ., concur.  