A Harrisburg man was sentenced to 3-1/2 to 7 years in state prison this morning for having sex with a 12-year-old girl who a prosecutor said was involved in a contest with her cousin to see who could lose her virginity first.

Hector Cervantes Jr., 20, pleaded guilty in December to charges that he molested the 12-year-old in August 2009. He was arrested later that year after a tipster reported to Harrisburg School District officials that the girl had been abused, Chief Deputy District Attorney Jennifer Gettle said.

Gettle said it is unclear whether Cervantes knew about the virginity-loss contest. He pleaded guilty to charges including statutory sexual assault and indecent assault.

The prison sentence imposed by Dauphin County Judge John F. Cherry was part of a plea deal. Cherry also ordered Cervantes to serve 5 years of probation after being released from prison.