Under construction

Still being built. Things may change

Float Lanterns

Time limit1sMemory limit1024 MB

Summary
Pick S consecutive lanterns and count pairs where a later-released lantern rises faster than an earlier one; output the maximum count over all windows.
Level

Hard8 of 10

Topics
Sliding window, Divide and conquer, Array
Solved
No attempts yet

Problem

Geonguseu prepared NN lanterns that rise without limit into the sky to close out the festival. The lanterns are numbered 11 to NN from left to right, and lantern ii rises by AiA_i every second. At the start, all lanterns are placed at height 00. When the festival ends, Geonguseu will pick SS consecutive lanterns and release them one second apart, in order of increasing number.

When one lantern overtakes other lanterns, people make one wish for each lantern it overtakes. Geonguseu wants to choose the lanterns to release so that people make as many wishes as possible. Among all ways to pick SS consecutive lanterns, what is the maximum number of wishes people can make?

Input

The first line contains the number of lanterns NN and the number of lanterns to release SS, separated by a space. (2≤N≤100000; 1≤S≤N)\left( 2 \leq N \leq 100000;\ 1 \leq S \leq N \right)

The second line contains NN integers AiA_i, separated by spaces, where AiA_i is how much lantern ii rises each second. (1≤Ai≤109)\left( 1 \leq A_i \leq 10^{9} \right)

Output

Print the number of wishes people make when Geonguseu chooses the lanterns to release so that this number is as large as possible.

Examples4

  1. Example 1

    Input
    4 4
    1 3 7 1
    
    Expected output
    3
    
  2. Example 2

    Input
    5 3
    10 17 19 7 10
    
    Expected output
    3
    
  3. Example 3

    Input
    10 10
    1 2 3 4 5 6 7 8 9 10
    
    Expected output
    45
    
  4. Example 4

    Input
    10 9
    1 2 3 4 5 6 7 8 9 10
    
    Expected output
    36