SANDPOINT, Idaho – The man who shot two Bonner County deputies was sentenced to 50 years in prison Tuesday afternoon.

Adam Foster, 32, pleaded guilty to two counts of attempted murder.

Deputies Michael Gagnon, Justin Penn and William Craffey were trying to arrest Foster on an outstanding arrest warrant in January 2017 in Blanchard. Officials said Foster was not listening to the commands from the deputies and ran away from them. Foster later fired a gun at the deputies. He hit two of them. They fired back, hitting and injuring Foster.

Bonner Co. Sheriff Daryl Wheeler said Deputy Penn was just recently cleared to return to duty. Deputy Gagnon has been back on duty for some time.

Several law enforcement officers, including the two deputies who were injured, were in the courtroom Tuesday afternoon. During the hearing, the courtroom watched body cam video of the shooting.

Deputy Gagnon’s wife gave a victim impact statement. She said Gagnon suffered from PTSD after the shooting and she has had anxiety as a result. Deputy Penn also spoke at the hearing. He said Foster acted as a coward. He said he feared his life was over immediately after being shot.

“We were left for dead, laying bloody in the snow," he said. "The shots happened so quick, it was hard to comprehend. As each one hit me, it felt as if someone struck me with a sledgehammer."

Then, Deputy Gagnon addressed Foster directly and said, “Adam, I can show you my scars that prove I was there.”

Foster’s own mother also spoke at the sentencing. The defense asked her about Foster’s behavior. A psychologist who performed a competency evaluation on Foster spoke as well. He said Foster was delusional and manic. He said even on medication, Foster is mildly impaired. Foster believed people were after him, including the KKK. He had also claimed that he did not see the deputies but saw "thugs" instead.

In closing, prosecutor said Foster was aware Gagnon and Penn were law enforcement officers. They said he made a decision to shoot them and it was his intent was to murder those officers.

"But that truly was an ambush. And his intent was to murder - specific intent - was to murder those two officers," Bonner County Prosecutor Louis Marshall said.

The defense said since Idaho does not have an insanity defense, they should consider Foster’s mental health issues. He has made some improvements during treatment while in custody.

The judge took Foster's mental illness into account saying that without that, she would have imposed a stiffer sentence.

Foster was then sentenced to 50 years in prison with 25 years fixed and 25 years indeterminate. He will be eligible for parole after 25 years.