2017-03-10 01:10:37 -06:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-03-10 01:10:37 -06:00
|
|
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
public class Solution {
|
2017-09-11 09:32:17 -07:00
|
|
|
public static void main(String[] args) {
|
2017-04-05 18:42:35 -05:00
|
|
|
/* Save input */
|
2017-03-10 01:10:37 -06:00
|
|
|
Scanner scan = new Scanner(System.in);
|
|
|
|
|
int n = scan.nextInt();
|
|
|
|
|
int k = scan.nextInt();
|
|
|
|
|
int [] height = new int[n];
|
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
|
height[i] = scan.nextInt();
|
|
|
|
|
}
|
|
|
|
|
scan.close();
|
|
|
|
|
|
|
|
|
|
/* Calculate # of magic beverages needed */
|
|
|
|
|
int maxHeight = Arrays.stream(height).max().getAsInt();
|
|
|
|
|
System.out.println(Math.max(maxHeight - k, 0));
|
|
|
|
|
}
|
|
|
|
|
}
|