Retirement tax questions

Dear sir, 

If any distribution happened after the excess contribution period,   how to calculate the gain and loss? Many thanks.