Find the capacity of 2D printed objects In a fictional 2D world, a set of 2D printing instructions for an object can be represented by a list of integers as follows:
1 4 2 1 1 2 5 3 4

Each number represents the height of the object at that particular point. The above list translates to the following object when printed:
      #
 #    # #
 #    ###
 ##  ####
#########

We then fill it with as much water as we can, resulting in this:
      #
 #~~~~#~#
 #~~~~###
 ##~~####
#########

We define the capacity of the object to be the  units of water the object can hold when completely full; in this case, 11.
Strictly speaking, a unit of water (~) can exist at a location if and only if it is surrounded by two solid blocks (#) in the same row.
Challenge
Take a list of positive integers as input (in any format), and output the capacity of the object printed when the list is used as instructions.
You can assume the list contains at least one element and all elements are between 1 and 255.
Test Cases
+-----------------+--------+
|      Input      | Output |
+-----------------+--------+
| 1               |      0 |
| 1 3 255 1       |      0 |
| 6 2 1 1 2 6     |     18 |
| 2 1 3 1 5 1 7 1 |      7 |
| 2 1 3 1 7 1 7 1 |      9 |
| 5 2 1 3 1 2 5   |     16 |
| 80 80 67 71     |      4 |
+-----------------+--------+
Haskell, 54 bytes
f l=(sum$zipWith min(scanl1 max l)$scanr1 max l)-sum l

The expressions scanl1 max l and scanr1 max l compute the running maximum of the list reading forwards and backwards, i.e. the profile of the water plus land if water would go flow one direction.
Orig:
      #
 #    # #
 #    ###
 ##  ####
#########

Left:
      #~~
 #~~~~#~#
 #~~~~###
 ##~~####
#########

Right:
~~~~~~#
~#~~~~#~#
~#~~~~###
~##~~####
#########

Then, the profile of the overall picture is the minimum of these, which corresponds to where the water does not leak either direction.
Minimum:
      #
 #~~~~#~#
 #~~~~###
 ##~~####
#########

Finally, the amount of water is the sum of this list, which contains both water and land, minus the sum of the original list, which contains only land.