#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cmath>
#define gi(x) scanf("%d",&x)
#define pi(x) printf("%d ",x)
#define pin(x) printf("%d\n",x);
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int lim = 2005;
typedef long long LL;
typedef pair<int,int> pii;
int n,h;
int a[lim];
LL dp[lim][lim];
void fill_dp()
{
for(int i=0;i<lim;i++)
for(int j=00;j<lim;j++)
dp[i][j]=(LL)0;
if(a[0] == h-1 || a[0] == h)
dp[0][0] = (LL)1;
if(a[0] == h-1)
dp[0][1] = (LL)1;
for(int i=1;i<n;i++)
{
for(int j=0;j<=i+1;j++)
{
if(a[i] + j == h)
{
dp[i][j] += dp[i-1][j-1];
dp[i][j] += dp[i-1][j];
}
if(a[i] + j == h-1)
{
dp[i][j] += (LL)dp[i-1][j+1]*(j+1);
dp[i][j] += dp[i-1][j];
dp[i][j] += (LL)dp[i-1][j]*j;
}
}
}
}
int main()
{
cin >> n;
cin >> h;
for(int i=0;i<n;i++)
{
cin >> a[i];
}
fill_dp();
cout << dp[n-1][0] << "\n";
return 0;
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxjc3RkbGliPgojaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8dXRpbGl0eT4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxtYXA+CiNpbmNsdWRlPHF1ZXVlPgojaW5jbHVkZTxzdGFjaz4KI2luY2x1ZGU8dmVjdG9yPgojaW5jbHVkZTxzdHJpbmc+CiNpbmNsdWRlPGNtYXRoPgoKI2RlZmluZSBnaSh4KSBzY2FuZigiJWQiLCZ4KQojZGVmaW5lIHBpKHgpIHByaW50ZigiJWQgIix4KQojZGVmaW5lIHBpbih4KSBwcmludGYoIiVkXG4iLHgpOwojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIGZpIGZpcnN0CiNkZ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