How is lines 5-8 of form 5329 calculated?
Assuming you meant IRS Form 5329, here's the IRS instructions, just go to page 3 of the instructions and enter the excluded amount, it should be rather self-explanatory:
https://www.irs.gov/pub/irs-pdf/i5329.pdf