#include <bits/stdc++.h>
#define f first
#define s second
#define m_p make_pair
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int M=1e9+7;
void add(int &a,int b){
a+=b;
if(a>=M) a-=M;
else if(a<0) a+=M;
}
int mult(int a,int b){
return 1ll*a*b%M;
}
const int N=200+2;
const int L=1'000+2;
int dp[N][N][L][2][2];
/// памяти пизда
/// i, todel_cnt,summod,wanttodel fi,wanttodel last
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n,k;
cin>>n>>k;
vec<int>a(n);
for(auto &z : a)
cin>>z;
sort(all(a));
for(int t=0;t<2;t++){
int i=0;
int d=(i+1<n?a[i+1]-a[i]:0);
for(int t1=0;t1<2;t1++){
if((t+t1)*d<=k)
dp[i+1][0][d*(t+t1)][t][t1]=1;
}
}
// vec<int> how(k+1,0);
auto check=[&](){
do{
int s=0;
for(int i=1;i<n;i++)
s+=abs(a[i]-a[i-1]);
if(s<=k)
how[s]++;
}while(next_permutation(all(a)));
};
// check();
// for(auto &z : a) cout<<z<<' ';
// cout<<endl;
for(int i=1;i<n;i++){
int d=(i+1<n?a[i+1]-a[i]:0);
for(int c=0;c<=i;c++){
for(int s=0;s<=k;s++){
/// one middle
for(int t=0;t<2;t++){
for(int t1=0;t1<2;t1++){
if(c){
if(s+2*(c-1)*d+(t+t1)*d<=k)
add(dp[i+1][c-1][s+2*(c-1)*d+(t+t1)*d][t][t1],mult(c,dp[i][c][s][t][t1]));
if(s+2*(c)*d+(t+t1)*d<=k)
add(dp[i+1][c][s+2*(c)*d+(t+t1)*d][t][t1],mult(c,mult(2,dp[i][c][s][t][t1])));
if(s+2*(c+1)*d+(t+t1)*d<=k)
add(dp[i+1][c+1][s+2*(c+1)*d+(t+t1)*d][t][t1],mult(c,dp[i][c][s][t][t1]));
}
}
}
/// first
for(int t1=0;t1<2;t1++){
int t=1;
if(s+2*c*d+(0+t1)*d<=k)
add(dp[i+1][c][s+2*c*d+(0+t1)*d][0][t1],dp[i][c][s][t][t1]);
if(s+2*c*d+(1+t1)*d<=k)
add(dp[i+1][c][s+2*c*d+(1+t1)*d][1][t1],dp[i][c][s][t][t1]);
if(s+2*(c+1)*d+(0+t1)*d<=k)
add(dp[i+1][c+1][s+2*(c+1)*d+(0+t1)*d][0][t1],dp[i][c][s][t][t1]);
if(s+2*(c+1)*d+(1+t1)*d<=k)
add(dp[i+1][c+1][s+2*(c+1)*d+(1+t1)*d][1][t1],dp[i][c][s][t][t1]);
}
/// last
for(int t=0;t<2;t++){
int t1=1;
if(s+2*c*d+(0+t)*d<=k)
add(dp[i+1][c][s+2*c*d+(t+0)*d][t][0],dp[i][c][s][t][t1]);
if(s+2*c*d+(1+t)*d<=k)
add(dp[i+1][c][s+2*c*d+(t+1)*d][t][1],dp[i][c][s][t][t1]);
if(s+2*(c+1)*d+(0+t)*d<=k)
add(dp[i+1][c+1][s+2*(c+1)*d+(t+0)*d][t][0],dp[i][c][s][t][t1]);
if(s+2*(c+1)*d+(1+t)*d<=k)
add(dp[i+1][c+1][s+2*(c+1)*d+(t+1)*d][t][1],dp[i][c][s][t][t1]);
}
}
}
// cout<<dp[2][0][2][1][0]<<endl;
}
int ans=0;
for(int s=0;s<=k;s++){
// cout<<"S "<<s<<' '<<dp[n][0][s][0][0]<<' '<<how[s]<<endl;
add(ans,dp[n][0][s][0][0]);
}
cout<<ans;
return 0;
}
/*
5 14
3 7 1 5 10
1 3 5 7 10
11 2
aa
ab
aa
ca
aa
bc
ea
aa
ad
de
aa
*/
Compilation message
skyscraper.cpp: In lambda function:
skyscraper.cpp:53:17: error: 'how' was not declared in this scope; did you mean 'pow'?
53 | how[s]++;
| ^~~
| pow