• + 0 comments

    import java.util.*;

    public class Solution {

    public static int hurdleRace(int k, List<Integer> height) {
        int maxHurdle = Collections.max(height);
        return Math.max(0, maxHurdle - k);
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        int n = scanner.nextInt(); // number of hurdles
        int k = scanner.nextInt(); // max jump height
    
        List<Integer> height = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            height.add(scanner.nextInt());
        }
    
        int result = hurdleRace(k, height);
        System.out.println(result);
    
        scanner.close();
    }
    

    }