#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
#define inp_s ios_base::sync_with_stdio(false)
#define DRT() int test_case;cin>>test_case;while(test_case--)
#define VI vector<int>
#define VS vector<string>
#define VLL vector<LL>
#define PII pair<int,int>
#define all(c) c.begin(),c.end()
#define sz(c) c.size()
#define clr(c) c.clear()
#define msi map<string,int>
#define msit map<string,int>::iterator
#define pb push_back
#define mp make_pair
#define GI(x) scanf("%d",&x)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=b-1;i>=a;i--)
#define gcd(a,b) __gcd(a,b)
#define MOD 1000000007
#define EPS 1E-10
#define PI acos(-1)
#define endn "\n"
#define CASE(x) cout << "Case #" << x << ": ";
VLL segTree(4000000);
VLL lazy(4000000);
int n;
LL query(int idx,int l,int r,int pos)
{
if(lazy[pos])
{
segTree[pos] += (lazy[pos] * (r-l+1));
segTree[pos] %= MOD;
if(l != r)
{
lazy[2*pos] += lazy[pos];
lazy[2*pos + 1] += lazy[pos];
lazy[2*pos] %= MOD;
lazy[2*pos+1] %= MOD;
}
lazy[pos] = 0;
}
if(l > idx || r < idx || l > r) return INT_MIN;
if(l == r && r == idx) return segTree[pos];
int mid = (l + r)/2;
return max( query(idx,l,mid,2*pos) , query(idx,mid+1,r,2*pos+1) );
}
LL getVal(int i)
{
return query(i,1,n+1,1);
}
void range_update(int qLeft,int qRight,LL val,int l,int r,int pos)
{
if(lazy[pos])
{
segTree[pos] += (lazy[pos] * (r-l+1));
segTree[pos] %= MOD;
if(l != r)
{
lazy[2*pos] += lazy[pos];
lazy[2*pos + 1] += lazy[pos];
lazy[2*pos] %= MOD;
lazy[2*pos+1] %= MOD;
}
lazy[pos] = 0;
}
if(l > qRight || r < qLeft || l > r) return ;
if(l >= qLeft && r <= qRight)
{
lazy[pos] += val;
lazy[pos] %= MOD;
return ;
}
int mid = (l + r)/2;
range_update(qLeft,qRight,val,l,mid,2*pos);
range_update(qLeft,qRight,val,mid+1,r,2*pos+1);
}
int main()
{
int h;
cin >> n >> h;
VLL arr(n+1);
arr[0] = 0;
FOR(i,1,n+1) cin >> arr[i];
FOR(i,1,n+1) arr[i] = arr[i-1] + arr[i];
range_update(1,1,1,1,n+1,1);
FOR(i,0,n+1)
{
int lb = i + 1;
int ub = (int)(upper_bound(all(arr) , arr[i] + h) - arr.begin()) - 1;
LL val = getVal(i+1);
if(lb <= ub)
range_update(lb+1,ub+1,val,1,n+1,1);
}
cout << getVal(n+1) << endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBsb25nIGludCBMTDsKCiNkZWZpbmUgaW5wX3MgICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpCiNkZWZpbmUgRFJUKCkgICAgIGludCB0ZXN0X2Nhc2U7Y2luPj50ZXN0X2Nhc2U7d2hpbGUodGVzdF9jYXNlLS0pCgojZGVmaW5lIFZJICAgICAgICB2ZWN0b3I8aW50PgojZGVmaW5lIFZTICAgICAgICB2ZWN0b3I8c3RyaW5nPgojZGVmaW5lIFZMTCAgICAgICB2ZWN0b3I8TEw+CiNkZWZpbmUgUElJICAgICAgIHBhaXI8aW50LGludD4KI2RlZmluZSBhbGwoYykgICAgYy5iZWdpbigpLGMuZW5kKCkKI2RlZmluZSBzeihjKSAgICAgYy5zaXplKCkKI2RlZmluZSBjbHIoYykgICAgYy5jbGVhcigpCiNkZWZpbmUgbXNpICAgICAgIG1hcDxzdHJpbmcsaW50PgojZGVmaW5lIG1zaXQgICAgICBtYXA8c3RyaW5nLGludD46Oml0ZXJhdG9yCiNkZWZpbmUgcGIgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIG1wICAgICAgICBtYWtlX3BhaXIKCiNkZWZpbmUgR0koeCkgICAgIHNjYW5mKCIlZCIsJngpCgojZGVmaW5lIEZPUihpLGEsYikgICAgICBmb3IoaW50IGk9YTtpPGI7aSsrKQoj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