/*
#include <stdio.h>
int main()
{
int n,arr[11]={};
for (int i=1;i<=10;i++)
{
scanf("%d", &arr[i]);
}
scanf("%d", &n);
for (int i=1;i<=10;i++)
{
if (i==n)
{
printf("%d", arr[i]);
}
}
}
*/
/*
#include <stdio.h>
int main()
{
int n,arr[1001]={};
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d", &arr[i]);
}
for (int i=1;i<=n;i++)
{
printf("%d: ", i);
for (int j=1;j<=n;j++)
{
if (i!=j)
{
if (arr[i] < arr[j])
{
printf("< ");
}
else if (arr[i] == arr[j])
{
printf("= ");
}
else
{
printf("> ");
}
}
}
printf("\n");
}
}
*/
/*
#include <stdio.h>
int main()
{
int up=0, down=0, arr[11]={};
double sum=0;
for (int i=1;i<=10;i++)
{
scanf("%d", &arr[i]);
sum += arr[i];
}
printf("%.1lf\n", sum/10);
for (int i=1;i<=10;i++)
{
if (arr[i] >= sum/10)
{
up++;
}
else
{
down++;
}
}
printf("%d %d", up,down);
}
*/
/*
#include <stdio.h>
int main()
{
int n,arr[10000]={};
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d", &arr[i]);
}
for (int i=n;i>=1;i--)
{
printf("%d ", arr[i]);
}
}
*/
/*
#include <stdio.h>
int main()
{
int n,min=23,arr[10000]={};
scanf("%d", &n);
for (int i=1;i<=n;i++)
{
scanf("%d", &arr[i]);
if(arr[i]<min)
{
min = arr[i];
}
}
printf("%d", min);
}
*/
#include <stdio.h>
int main()
{
int w,d,sum=0,max=-100,arr[100000]={};
scanf("%d %d", &w,&d);
for (int i=1;i<=w;i++)
{
scanf("%d", &arr[i]);
}
for (int i=1;i<=w;i++)
{
for (int j=i;j<=i+d-2;j++)
{
printf("%d ", arr[j-1]+arr[j]);
if (arr[j-1]+arr[j]>max)
{
max=arr[j-1]+arr[j];
}
}
}
printf("\n%d", max);
}



