Measuring a pile of logs
Jelly, 19 13 bytes

IN0»0;+\+"RṬS


Try it online!

Saved 2 bytes thanks to @Jonathan Allan.

Explanation

IN0»0;+\+"RṬS  Input: array A
I              Increments
 N             Negate
  0»           Max with 0
    0;         Prepend 0
      +\       Cumulative sum
        +"     Vectorized add with
          R    Range, vectorizes over each integer
           Ṭ   Create a list with 1's at the specified indices
            S  Sum