All problems

Charting a Cumulative Running Total

mediumPythonSeaborncumsum

Halden Cycle Hire's finance team tracks money in and out of the hire account, one figure per day, refunds included as negative amounts. The chart they publish shows the balance building up over the month rather than the daily swings, and the month-end note has to state where that balance finished.

Task: Print the running total after the last day has been applied.

Input

The first line holds one integer n, the number of days, where 1 <= n <= 1000. Then come n lines, one amount each, oldest first. An amount may be negative, which is a refund going back out of the account.

Output

One line holding the running total once every amount has been applied, rounded to 2 decimal places. That is the closing figure, which is not necessarily the highest the running total reached during the month.

Example:

Input:
4
10
20
-5
15

Output:
40.00

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…