{$mode objfpc}
uses math;
const
finp = '';
fout = '';
modulo = trunc(1e9+7);
maxn = 2000;
var
fi,fo : text;
n,h : integer;
f : array[1..maxn,0..maxn] of int64;
a : array[1..maxn] of integer;
procedure openfile;
begin
assign(fi,finp);reset(fi);
assign(fo,fout);rewrite(fo);
end;
procedure closefile;
begin
close(fi);close(fo);
end;
procedure enter;
var
i : integer;
begin
readln(fi,n,h);
for i:=1 to n do
read(fi,a[i]);
end;
procedure add(var a:int64;b:int64);
begin
a:=(a+b) mod modulo;
end;
procedure process;
var
i,j : integer;
begin
//Tai 1 [] hoac do no thing
f[1][0]:=ord((a[i]=h) or (a[i]+1=h));
//Tai 1 [
f[1][1]:=ord(a[i]+1=h);
for i:=2 to n do
for j:=max(h-a[i]-1,0) to min(h-a[i],i) do
begin
//
if j+a[i]=h then
begin
//Tai i [
if j>0 then
add(f[i,j],f[i-1,j-1]);
//Do no thing
add(f[i,j],f[i-1,j]);
end
else
if j+a[i]+1=h then
begin
//Tai i ]
add(f[i,j],f[i-1,j+1]*(j+1));
//Tai i []
add(f[i,j],f[i-1,j]);
//Tai i ][
add(f[i,j],f[i-1,j]*j);
end;
end;
writeln(fo,f[n,0]);
end;
begin
openfile;
enter;
process;
closefile;
end.
eyRtb2RlIG9iamZwY30KdXNlcyBtYXRoOwpjb25zdAogICAgICAgICAgICAgICAgZmlucCAgICAgICAgICAgID0gICAgICAgICAgICAgICAnJzsKICAgICAgICAgICAgICAgIGZvdXQgICAgICAgICAgICA9ICAgICAgICAgICAgICAgJyc7CiAgICAgICAgICAgICAgICBtb2R1bG8gICAgICAgICAgPSAgICAgICAgICAgICAgIHRydW5jKDFlOSs3KTsKICAgICAgICAgICAgICAgIG1heG4gICAgICAgICAgICA9ICAgICAgICAgICAgICAgMjAwMDsKdmFyCiAgICAgICAgICAgICAgICBmaSxmbyAgICAgICAgICAgOiAgICAgICAgICAgICAgIHRleHQ7CiAgICAgICAgICAgICAgICBuLGggICAgICAgICAgICAgOiAgICAgICAgICAgICAgIGludGVnZXI7CiAgICAgICAgICAgICAgICBmICAgICAgICAgICAgICAgOiAgICAgICAgICAgICAgIGFycmF5WzEuLm1heG4sMC4ubWF4bl0gb2YgaW50NjQ7CiAgICAgICAgICAgICAgICBhICAgICAgICAgICAgICAgOiAgICAgICAgICAgICAgIGFycmF5WzEuLm1heG5dIG9mIGludGVnZXI7CnByb2NlZHVyZSBvcGVuZmlsZTsKYmVnaW4KICAgICAgICBhc3NpZ24oZmksZmlucCk7cmVzZXQoZmkpOwogICAgICAgIGFzc2lnbihmbyxmb3V0KTtyZXdyaXRlKGZvKTsKZW5kOwpwcm9jZWR1cmUgY2xvc2VmaWxlOwpiZWdpbgogICAgICAgIGNsb3NlKGZpKTtjbG9zZShmbyk7CmVuZDsKcHJvY2VkdXJlIGVudGVyOwp2YXIKICAgICAgICBpICAgICAgICAgICAgICAgOiAgICAgICAgICAgICAgIGludGVnZXI7CmJlZ2luCiAgICAgICAgcmVhZGxuKGZpLG4saCk7CiAgICAgICAgZm9yIGk6PTEgdG8gbiBkbwogICAgICAgICAgICAgICAgcmVhZChmaSxhW2ldKTsKZW5kOwpwcm9jZWR1cmUgYWRkKHZhciBhOmludDY0O2I6aW50NjQpOwpiZWdpbgogICAgICAgIGE6PShhK2IpIG1vZCBtb2R1bG87CmVuZDsKcHJvY2VkdXJlIHByb2Nlc3M7CnZhcgogICAgICAgIGksaiAgICAgICAgICAgICA6ICAgICAgICAgICAgICAgaW50ZWdlcjsKYmVnaW4KICAgICAgICAvL1RhaSAxIFtdIGhvYWMgZG8gbm8gdGhpbmcKICAgICAgICBmWzFdWzBdOj1vcmQoKGFbaV09aCkgb3IgKGFbaV0rMT1oKSk7CiAgICAgICAgLy9UYWkgMSBbCiAgICAgICAgZlsxXVsxXTo9b3JkKGFbaV0rMT1oKTsKICAgICAgICBmb3IgaTo9MiB0byBuIGRvCiAgICAgICAgZm9yIGo6PW1heChoLWFbaV0tMSwwKSB0byBtaW4oaC1hW2ldLGkpIGRvCiAgICAgICAgYmVnaW4KICAgICAgICAgICAgICAgIC8vCiAgICAgICAgICAgICAgICBpZiBqK2FbaV09aCB0aGVuCiAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICAvL1RhaSBpIFsKICAgICAgICAgICAgICAgICAgICAgICAgaWYgaj4wIHRoZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhZGQoZltpLGpdLGZbaS0xLGotMV0pOwogICAgICAgICAgICAgICAgICAgICAgICAvL0RvIG5vIHRoaW5nCiAgICAgICAgICAgICAgICAgICAgICAgIGFkZChmW2ksal0sZltpLTEsal0pOwogICAgICAgICAgICAgICAgZW5kCiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICBpZiBqK2FbaV0rMT1oIHRoZW4KICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgICAgICAgIC8vVGFpIGkgXQogICAgICAgICAgICAgICAgICAgICAgICBhZGQoZltpLGpdLGZbaS0xLGorMV0qKGorMSkpOwogICAgICAgICAgICAgICAgICAgICAgICAvL1RhaSBpIFtdCiAgICAgICAgICAgICAgICAgICAgICAgIGFkZChmW2ksal0sZltpLTEsal0pOwogICAgICAgICAgICAgICAgICAgICAgICAvL1RhaSBpIF1bCiAgICAgICAgICAgICAgICAgICAgICAgIGFkZChmW2ksal0sZltpLTEsal0qaik7CiAgICAgICAgICAgICAgICBlbmQ7CiAgICAgICAgZW5kOwogICAgICAgIHdyaXRlbG4oZm8sZltuLDBdKTsKZW5kOwpiZWdpbgogICAgICAgIG9wZW5maWxlOwogICAgICAgIGVudGVyOwogICAgICAgIHByb2Nlc3M7CiAgICAgICAgY2xvc2VmaWxlOwplbmQu