#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<map>
#include<stdlib.h>
#include<time.h>
using namespace std;
#define sd(a) scanf("%lld",&a)
#define pd(a) printf("%d\n",(a))
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define mod 1000000007
pair<long long,long long> h[500010];
long long dp[500010];
long long s[500010];
int main()
{
long long n,m,i,pos;
sd(n);
sd(m);
for(i=1;i<=n;++i)
{
sd(h[i].F);
h[i].S=i;
}
h[0]=MP(0,0);
for(i=2;i<=n;++i)
h[i].F=h[i-1].F+h[i].F;
dp[0]=1;
s[0]=1;
for(i=1;i<=n;++i)
{
pos=(*(lower_bound(h,h+n+1,MP(h[i].F-m,(long long)-1)))).S;
dp[i]=s[i-1];
if(pos>0)
dp[i]=(dp[i]-s[pos-1]+mod)%mod;
s[i]=(s[i-1]+dp[i])%mod;
}
printf("%lld\n",dp[n]);
}
I2luY2x1ZGU8Y3N0ZGlvPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPHZlY3Rvcj4KI2luY2x1ZGU8Y3N0cmluZz4KI2luY2x1ZGU8Y21hdGg+CiNpbmNsdWRlPHN0YWNrPgojaW5jbHVkZTxxdWV1ZT4KI2luY2x1ZGU8c3RyaW5nPgojaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8bWFwPgojaW5jbHVkZTxzdGRsaWIuaD4KI2luY2x1ZGU8dGltZS5oPiAgCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZSBzZChhKSBzY2FuZigiJWxsZCIsJmEpCiNkZWZpbmUgcGQoYSkgcHJpbnRmKCIlZFxuIiwoYSkpCiNkZWZpbmUgTEwgbG9uZyBsb25nCiNkZWZpbmUgRiBmaXJzdAojZGVmaW5lIFMgc2Vjb25kCiNkZWZpbmUgTVAgbWFrZV9wYWlyCiNkZWZpbmUgUEIgcHVzaF9iYWNrCiNkZWZp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