PROVIDENCE, R.I. — A Massachusetts man has pleaded no contest to randomly stabbing an employee at a Rhode Island Rite-Aid.

The Rhode Island attorney general’s office says 42-year-old Jacob Gallant, of Westport, pleaded no contest Friday to assault with intent to murder, mayhem and a weapons charge. Superior Court Magistrate John McBurney sentenced him to serve 25 years in prison, followed by 20 years suspended with probation.

Prosecutors had requested he be sentenced to 45 years to serve.

Authorities say Gallant was carrying a large butcher knife when he walked into a Rite-Aid in Warwick and repeatedly stabbed 18-year-old Alyssa Garcia in March. Garcia was severely injured.

Police say Gallant told them he “just went nuts,” and bought the knife that day because he “wanted to kill someone” but didn’t know who.