#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 1e3 + 5;
int n,m;
int dp[N][N],a[N];
template <typename T> inline void read(T &x){
x = 0;int t = 1;char c = getchar();
for(;!isdigit(c);c = getchar()){
if(c == '-'){
t = -1;
}
}
for(;isdigit(c);c = getchar()){
x = (x << 1) + (x << 3) + (c ^ 48);
}
x = t * x;
}
template <typename T> void print(T x){
if (x < 0){
x *= -1;
putchar('-');
}
if(x > 9){
print(x / 10);
}
putchar(x % 10 + 48);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
read(n);
read(m);
for(int i = 1;i <= n;i++){
read(a[i]);
}
for(int i = 0 ;i <= m;i++){
dp[0][i] = 1;
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= m;j++){
for(int k = 0;k <= j && k <= a[j] && k <= i;k++){
dp[i][j] = (dp[i - k][j - 1] + dp[i][j]);
}
}
}
print(dp[n][m] % 1000007);
return 0;
}