#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#include<vector>
int main() {
// your code goes here
vector<int>arr={2,1,1,5,8};
int n=arr.size();
int k=4;
int count=0,sum=0,i=0,j=0;
while(i<n && j<n)
{
sum+=arr[j];
while(sum>k)
{
sum=sum-arr[i];
i++;
}
//if(sum<=k)
count+=(j-i+1);
j++;
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KI2luY2x1ZGU8dmVjdG9yPgoKaW50IG1haW4oKSB7CgkvLyB5b3VyIGNvZGUgZ29lcyBoZXJlCgl2ZWN0b3I8aW50PmFycj17MiwxLDEsNSw4fTsKCWludCBuPWFyci5zaXplKCk7CglpbnQgaz00OwoJaW50IGNvdW50PTAsc3VtPTAsaT0wLGo9MDsKCXdoaWxlKGk8biAmJiBqPG4pCgkgewoJICAgCXN1bSs9YXJyW2pdOwoJICAgCXdoaWxlKHN1bT5rKQoJICAgCSB7CgkgICAJIAlzdW09c3VtLWFycltpXTsKCSAgIAkgCWkrKzsKCSAgIAkgfQoJICAgCSAvL2lmKHN1bTw9aykKCSAgIAkgICAgY291bnQrPShqLWkrMSk7CgkgICAJIGorKzsgICAKCSB9CgkgCgkgY291dDw8Y291bnQ7CgkgCglyZXR1cm4gMDsKfQ==