const
  maxn = 1000;
  maxv = 1000000000;
var
  n, k, i, j, l : integer;
  a, b, res : array[1..maxn] of integer;
  ns : array[1..maxn] of boolean;

procedure qsort(l, r : integer);
var
  i, j, x, t : integer;
begin
  if (l >= r) then exit;
  i := l;
  j := r;
  x := b[l + random(r - l + 1)];
  while (i <= j) do begin
    while (b[i] < x) do i := i + 1;
    while (b[j] > x) do j := j - 1;
    if (i <= j) then begin
      t := b[i]; b[i] := b[j]; b[j] := t;
      i := i + 1;
      j := j - 1;
    end;	
  end;
  qsort(l, j);
  qsort(i, r);
end;

begin
  reset(input, 'ksort.in');
  rewrite(output, 'ksort.out');
  read(n, k);
  assert((1 <= n) and (n <= maxn));
  assert((1 <= k) and (k <= maxv));
  for i := 1 to n do begin
    read(a[i]);
    assert((1 <= a[i]) and (a[i] <= maxv));
  end;
  for i := 1 to n do begin
    if not(ns[i]) then begin
      l := 0;
      for j := 1 to n do begin
        if (a[j] mod k) = (a[i] mod k) then begin
          l := l + 1;
          b[l] := a[j];
        end;
      end;
      qsort(1, l);
      l := 1;
      for j := 1 to n do begin
        if (a[j] mod k) = (a[i] mod k) then begin
          ns[j] := true;
          res[j] := b[l];
          l := l + 1;
        end;
      end;
    end;
  end;
  for i := 1 to n - 1 do begin
    if (res[i] > res[i + 1]) then begin
      writeln('NO');
      halt;
    end;
  end;
  writeln('YES');
end.
