Exclude capital gain in S corp stock sale in MA return

Sold shares in an SCorp in state (MN) where I am not a resident. How can I exclude the capital gain in state (MA) where I am a resident so that I won't be taxed twice for the same gain in two states?