Mud-Walls

A child likes to build mud walls by placing mud between sticks positioned on a number line. The gap between sticks will be referred to as a cell, and each cell will contain one segment of wall. The height of mud in a segment cannot exceed 1 unit above an adjacent stick or mud segment.

First line takes the no of sticks as input follwed by the position of the sticks. Then again no of sticks is got as input followed by the height of the sticks. These values are stored in arrays and sent as parameters to the function which will return the max height of the wall tat will be built between the sticks.

sample input : 4 1 2 4 7 4 4 5 7 11 sample output : 9