#K4201. Minimum Books Removal

    ID: 26992 Type: Default 1000ms 256MiB

Minimum Books Removal

Minimum Books Removal

You are given a set of racks with books. Each rack can hold at most c books. If a rack contains more than c books, the extra books must be removed. Given the number of racks m, the capacity c, and the list of numbers of books on each rack, your task is to compute the minimum number of books to remove so that no rack exceeds its capacity.

The formula to compute the removed books for a rack with b books is: \[ \text{removed} = \max(0, b - c) \]

The final answer is the sum of removed books across all racks.

inputFormat

The input is given via stdin with the following format:

  • The first line contains an integer m representing the number of racks.
  • The second line contains an integer c representing the capacity of each rack.
  • The third line contains m space-separated integers, where each integer denotes the number of books on a rack.

outputFormat

Output the minimum number of books to remove on a single line to ensure that no rack exceeds its capacity. The output should be printed to stdout.

## sample
5
10
12 5 14 8 7
6