Shading the Area Under a Curve
A flow meter at Northgate Water reports once an hour, and the operations note charts the readings as a line with the region between the line and the zero level shaded in, because what the shading covers is roughly the volume that passed through. Since the readings are one hour apart, each reading stands for one hour's worth, and the shaded region comes to the readings added together. The note carries that figure in words as well, and the figure is what is checked here.
Task: Print the total the shaded region represents.
Input
The first line holds an integer n, the number of readings. Each of the next n lines holds one reading. A reading may be zero.
Output
One line holding the readings added together, as a plain integer.
Example:
Input:
3
10
20
30
Output:
60
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