All problems

Charting Revenue Over Time

easyPythonMatplotlibLine Chart

Alderwood Supply's monthly pack charts revenue as a line, because the months run in order and the line makes the shape of the year visible at a glance. Above the chart sits one figure the board reads first: how much higher or lower revenue is in the last month of the period than it was in the first. A fall is written as a negative number, and a period that ends exactly where it started is written as zero. Nothing that happened in between affects this figure.

Task: Print the change in revenue from the first month to the last.

Input

The first line holds an integer n, the number of months. Each of the next n lines holds a month name and that month's revenue, separated by a single space. Months arrive in order and a name contains no spaces.

Output

One line holding the change as a plain integer, negative if revenue fell.

Example:

Input:
3
Jan 1000
Feb 1200
Mar 1500

Output:
500

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…