import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int d = Integer.parseInt(sa[1]); Obj[] arr = new Obj[n]; for (int i = 0; i < n; i++) { Obj o = new Obj(); o.a = Integer.parseInt(br.readLine()); o.i = i; arr[i] = o; } br.close(); Arrays.sort(arr, (o1, o2) -> o2.a - o1.a); int j = 1; for (int i = 0; i < n; i++) { while (j < n && arr[i].a - arr[j].a < d) { j++; } if (j < n && arr[i].a - arr[j].a >= d) { arr[i].ans = n - j; } } Arrays.sort(arr, (o1, o2) -> o1.i - o2.i); PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < n; i++) { pw.println(arr[i].ans); } pw.flush(); } static class Obj { int a, i, ans; } }