#C6218. Final Position on the Number Line
Final Position on the Number Line
Final Position on the Number Line
You are given a list of integers representing movement on a number line. Each integer indicates a step: positive values move you forward, negative values move you backward, and a zero means no move.
Your task is to compute the final position starting from 0, which is simply the sum of all the movement steps.
Input/Output Requirements: The solution must read input from stdin and write the result to stdout.
Note on Mathematical Expression: The final position, \( P \), is computed as \( P = \sum_{i=1}^{n} a_i \), where \( a_i \) is the i-th step.
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) (\( 0 \leq n \leq 10^5 \)) representing the number of steps.
- The second line contains \( n \) space-separated integers, each representing a movement step on the number line.
outputFormat
Output a single integer representing the final position on the number line after processing all the steps.
## sample5
3 -2 4 -1 2
6