I need to calculate my elevation gain and loss. Say I started at 1000 feet above sea level. Then, I go on a hike and go up and down hilly terrain. I might reach some different elevations:

- Start

1000

1030

1100

1150

1090

1220

1500

1350

1200

1092

1000

- End

Is there a calculation or formula that I can use to determine my total gain and loss based on my starting elevation of 1000?