/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Scanner s
= new Scanner
(System.
in);
// Input size of the array
int N = s.nextInt();
int[] a = new int[N];
// Input array elements
for (int i = 0; i < N; i++) {
a[i] = s.nextInt();
}
// Input the value of k
int k = s.nextInt();
// Sliding window logic
int si = 0, sum = 0, maxlen = 0;
for(int ei=0;ei<N;ei++) {
sum += a[ei]; // Expand the window
// Shrink the window while the sum exceeds k
while (sum > k) {
sum -= a[si];
si++;
}
// Update maxlen if the current window satisfies the condition
maxlen
= Math.
max(maxlen,
(ei
- si
) + 1);
}
// Output the result
s.close();
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgcyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgCiAgICAgICAgLy8gSW5wdXQgc2l6ZSBvZiB0aGUgYXJyYXkKICAgICAgICBpbnQgTiA9IHMubmV4dEludCgpOwogICAgICAgIGludFtdIGEgPSBuZXcgaW50W05dOwogICAgICAgIAogICAgICAgIC8vIElucHV0IGFycmF5IGVsZW1lbnRzCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyBpKyspIHsKICAgICAgICAgICAgYVtpXSA9IHMubmV4dEludCgpOwogICAgICAgIH0KICAgICAgICAKICAgICAgICAvLyBJbnB1dCB0aGUgdmFsdWUgb2YgawogICAgICAgIGludCBrID0gcy5uZXh0SW50KCk7CiAgICAgICAgCiAgICAgICAgLy8gU2xpZGluZyB3aW5kb3cgbG9naWMKICAgICAgICBpbnQgc2kgPSAwLCBzdW0gPSAwLCBtYXhsZW4gPSAwOwogICAgICAgIGZvcihpbnQgZWk9MDtlaTxOO2VpKyspIHsKICAgICAgICAgICAgc3VtICs9IGFbZWldOyAgLy8gRXhwYW5kIHRoZSB3aW5kb3cKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIFNocmluayB0aGUgd2luZG93IHdoaWxlIHRoZSBzdW0gZXhjZWVkcyBrCiAgICAgICAgICAgIHdoaWxlIChzdW0gPiBrKSB7CiAgICAgICAgICAgICAgICBzdW0gLT0gYVtzaV07CiAgICAgICAgICAgICAgICBzaSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBVcGRhdGUgbWF4bGVuIGlmIHRoZSBjdXJyZW50IHdpbmRvdyBzYXRpc2ZpZXMgdGhlIGNvbmRpdGlvbgogICAgICAgICAgICBtYXhsZW4gPSBNYXRoLm1heChtYXhsZW4sIChlaSAtIHNpKSArIDEpOwogICAgICAgICAgCiAgICAgICAgfQogICAgICAgIAogICAgICAgIC8vIE91dHB1dCB0aGUgcmVzdWx0CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKG1heGxlbik7CiAgICAgICAgCiAgICAgICAgcy5jbG9zZSgpOwogICAgfQp9Cg==