#include<iostream> #include<cstdio> #include<cmath> #define maxn 17 #define ll long long usingnamespacestd;
int n, a[maxn], m;
ll f[1 << maxn][maxn];
intmain(){ cin >> n >> m; int M = (1 << n) - 1; for (int i = 1; i <= n; ++i) cin >> a[i], f[1 << i - 1][i] = 1; for (int S = 1; S <= M; ++S) for (int i = 1; i <= n; ++i) { if (!(S >> i - 1 & 1)) continue; for (int j = 1; j <= n; ++j) { if ((S >> j - 1 & 1) || abs(a[j] - a[i]) <= m) continue; f[S | 1 << j - 1][j] += f[S][i]; } } ll ans = 0; for (int i = 1; i <= n; ++i) ans += f[M][i]; cout << ans << endl; }