A warehouse has n shelf columns, indexed 1..n, each starting at height 0. A forklift operation selects any contiguous range of columns [l, r] (of any length, including a single column) and raises every column in that range by exactly 1 unit. Given a target height array target[1..n] (all non-negative), determine the MINIMUM number of forklift operations needed so that every column ends up at exactly its target height (columns can only go up, and the final heights must equal the targets exactly - no more, no less). Print this minimum count.
Input format
Line 1: an integer n.
Line 2: n space-separated non-negative integers, the target heights.
Output format
A single integer: the minimum number of forklift operations required.
Constraints
- 1 <= n <= 100000
- 0 <= target[i] <= 1000000