A New Hampshire man who rode his bike to Maine and robbed a pharmacy in Kittery at knifepoint last year was sentenced Monday in federal court in Portland to more than three years in prison.

Robert Pecora, 26, of Dover, had pleaded guilty before U.S. District Judge Nancy Torresen on April 14 to a charge of robbery. Pecora also pleaded guilty to a charge of criminal contempt for running away from a drug treatment program last month while he was free on bail for the drugstore robbery, and for stealing guns, cash and a vehicle.

On Monday, Torresen sentenced Pecora to a total of 37 months in prison: 28 months for the robbery, followed by another nine months for the criminal contempt charge. She ordered him to serve three years of supervised release after the prison term.

On Sept. 21, 2013, Pecora showed a knife to an employee at the Rite-Aid on Shapleigh Road in Kittery and demanded “all of your Oxycontin.” He was given three bottles of pills and then shut himself in the store’s bathroom until police arrived, according to court records.

Pecora told Kittery police at the scene that he had robbed the store. Officers found light-blue pills and pill residue on the bathroom floor and a light-blue powdery residue on Pecora’s upper lip, according to an affidavit filed in his case by FBI Agent Thomas MacDonald.

Months after his arrest, the court allowed Pecora to be released on an unsecured bond of $5,000 so he could enter the Addiction Recovery Center in Dover, with a condition that he not leave the facility without permission from the U.S. Probation Office.

Pecora fled the center on March 20 and broke into a home in Greenland, New Hampshire, that night. He stole three firearms, about $1,000 in cash and a vehicle from the house and remained at large until he was arrested March 25 in Keene, New Hampshire, according to a prosecution document filed in federal court.

The three stolen firearms have yet to be recovered, according to the U.S. Attorney’s Office.

The judge also ordered Pecora to pay $563 in restitution and fees.