1031 Exchange

I had to move from AZ to IA for a medical emergency for my grandson. I didn't want to sell the AZ home but renting it turned into a nightmare. I sold it about 9 months after I moved to IA. Bought 3 IA properties ($280k) with the gain but from what I understand I still have to pay capital gains on the initial purchase of the AZ home ($290K).  I was in the AZ home for 2 years as my primary residence. Do I have to pay capital gains on my initial purchase price of $290K? Also, is there some sort of exemption since moving was due to a family medical emergency?