#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll MOD = 1000000007; int main() { int N, K; cin >> N >> K; int A[N]; for (int i = 0; i < N; ++i) { cin >> A[i]; } int dp[N + 1][K + N + 1]; memset(dp, 0, sizeof(dp)); for (int k = 0; k <= K; ++k) { dp[0][k] = 1; } for (int i = 0; i < N; ++i) { for (int j = 0; j <= K; ++j) { if (j - i - 1 >= 0) { dp[i + 1][j] += dp[i][j] - dp[i][j - i - 1]; } else { dp[i + 1][j] += dp[i][j]; } if (j != 0) dp[i + 1][j] += dp[i + 1][j - 1]; dp[i + 1][j] %= MOD; } } cout << dp[N][K] << endl; return 0; }