Covering a Skyline with brush strokes
JavaScript (Node.js), 38 bytes



a=&gt;a.map(v=&gt;(n+=v&gt;p&amp;&amp;v-p,p=v),p=n=0)|n


Try it online!

Simply a greedy algorithm which scan from left to right, only draw lines if needed, and draw it as long as possible.

Thanks Arnauld, save 2 3 bytes