#C11956. Minimum Potions Needed

    ID: 41329 Type: Default 1000ms 256MiB

Minimum Potions Needed

Minimum Potions Needed

Dave is preparing to race through a series of hurdles. However, he has a jump limit: he can jump over hurdles of height up to h without any assistance. If a hurdle is taller than h, Dave must use potions to boost his jump. Each potion increases his jump height by exactly 1 unit.

Your task is to determine the minimum number of potions that Dave needs in order to clear all the hurdles. Mathematically, if the maximum hurdle height is \(H_{max}\) and Dave's initial jump height is \(h\), then the number of potions required is given by:

[ \text{potions} = \max(0, H_{max} - h)
]

Help Dave figure out how many potions he needs!

inputFormat

The input is provided via standard input and consists of three lines:

  • The first line contains an integer \(n\), representing the number of hurdles.
  • The second line contains \(n\) space-separated integers, each representing the height of a hurdle.
  • The third line contains an integer \(h\), representing Dave's maximum jump height.

outputFormat

Output a single integer representing the minimum number of potions required for Dave to clear all hurdles. The output should be written to standard output.

## sample
5
1 2 3 3 2
3
0