#include<iostream>
#include<cstdio>
using namespace std;
int n,k,a[200005],sum[200005],ans;
bool check(int mid)
{	int mi=2000005;
   for(int i=1;i<=n;i++)
   {
   	
     	if(a[i]>=mid) sum[i]=sum[i-1]+1; 
   	    else sum[i]=sum[i-1]-1;
    if(i>=k) 
	{
	mi=min(mi,sum[i-k]); 
	}
	if(mi<sum[i])
     return true;
   }	
	return false;	
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
	scanf("%d",&a[i]);		
	} 
	int l=1,r=n;
	while(l<=r)
	{
		int mid=(l+r) >>1;
       if( check(mid))
        {
         l=mid+1; 	
ans=mid;
		}
	   else
	      r=mid-1;
	} 
printf("%d\n",ans);
	
	return 0;
}
 
