cswork / OAOpen practice workspace

AirbnbOA #1

Subarray Products

Estimated MediumJudge-ready

Topics (AI-labelled)Two Pointers

Count the non-empty contiguous subarrays whose product of elements does not exceed k; the comparison includes equality.

Input

The first line contains n, the second line contains n positive integers, and the third line contains k. 1≤n≤500000, 1≤a[i]≤100, 1≤k≤1000000.

Output

Output a single integer answer.

Example 1

Input:

3
2 3 4
6

Output:

4

Example 2

Input:

3
1 2 3
4

Output:

4

Example 3

Input:

3
1 1 1
1

Output:

6

Example notes

The outputs of the three public examples are, in order: 4; 4; 6. Verified by independent enumeration or direct simulation.

Editorial

Loading solution…