import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int arr[]=new int [n];
for(int i=0;i<n;i++)
arr[i]=sc.nextInt();
for(int i=0;i<=n-k;i++){
int max=0;
for(int j=0;j<k;j++){
if(arr[i+j]>max)
max=arr[i+j];
}
System.out.print(max + " ");
}
}
}
To embed this program on your website, copy the following code and paste it into your website's HTML: