import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int d = sc.nextInt(); Tune[] arr = new Tune[n]; for (int i = 0; i < n; i++) { arr[i] = new Tune(i, sc.nextInt()); } Arrays.sort(arr); int[] ans = new int[n]; int left = 0; for (int i = 0; i < n; i++) { while (arr[i].value - arr[left].value >= d) { left++; } ans[arr[i].idx] = left; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(ans[i]).append("\n"); } System.out.print(sb); } static class Tune implements Comparable { int idx; int value; public Tune(int idx, int value) { this.idx = idx; this.value = value; } public int compareTo(Tune another) { return value - another.value; } } }