#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
static FILE *fr, *fw;

// Declaring variables
static int N;
static long long M;
static int* V;
static int B;

bool check(ll N,ll B,ll M,vector<ll> a)
{
    ll sum_=0;
    for(int i=0;i<B;i++)
    {
        sum_+=a[i];
        if(sum_>M)
        {
            return false;
        }
    }
    for(int i=B;i<N;i++)
    {
        sum_+=a[i];
        sum_-=a[i-B];
        if(sum_>M)
        {
            return false;
        }
    }
    return true;
}

int quadri(int N, long long M, int* V)
{
    ll sol_=0;
    vector<ll> a(N);
    ll sum_=0;
    for(int i=0;i<N;i++)
    {
        a[i]=V[i];
        sum_+=V[i];
    }
    ll L=0;
    ll R=M+1;
    while(L<=R)
    {
        ll tm=(L+R)/2;
        if(check(N,tm,M,a))
        {
            L=tm+1;
            sol_=tm;
        }
        else
        {
            R=tm-1;
        }//TODO fare il cotnartio 

    }
    

    return sol_;

}
