Link to this code:
https://cses.fi/paste/92936dba4c962a4a286183//*
author: @ankingcodes
created: 2021-08-07 21:28:06.679416
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define INF 1e18
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int MOD = (int) 1e9 + 7;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> PBDS;
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> pairPBDS;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, x; cin >> n >> x;
vector<int> arr(n), dp(x+1, 0);
for (auto &i: arr) cin >> i;
dp[0] = 1; // base case
for (int i=1;i<=x;i++) {
for (int j=0;j<n;j++) {
if (i - arr[j] >= 0) {
dp[i] += dp[i-arr[j]];
dp[i] %= MOD;
}
}
}
cout << dp[x] << endl;
return 0;
}