Section 32D. (a) Any person who knowingly or intentionally manufactures, distributes, dispenses or possesses with intent to manufacture, distribute, or dispense a controlled substance in Class E of section thirty-one shall be imprisoned in a jail or house of correction for not more than nine months, or by a fine of not less than two hundred and fifty nor more than two thousand and five hundred dollars, or both such fine and imprisonment.
(b) Any person convicted of violating this section after one or more prior convictions of manufacturing, distributing, dispensing or possessing with the intent to manufacture, distribute or dispense a controlled substance as defined by section thirty-one under this or any prior law of this jurisdiction or of any offense of any other jurisdiction, federal, state, or territorial which is the same as or necessarily includes the elements of said offense shall be punished by a term of imprisonment in a jail or house of correction for not more than one and one-half years, or by a fine of not less than five hundred nor more than five thousand dollars, or both such fine and imprisonment.