#include<stdio.h>
#include<stdlib.h>

typedef struct cirlst
{
    int data;
    struct cirlst *next,*prev;
}node;

node *head=NULL,*tail=NULL;


void create(int n)
{
    node nd=(node)malloc(sizeof(node));
    nd->data=n;
    nd->prev=nd->next=NULL;
    
    if(head==NULL)
    {
        head=tail=nd;
    }
    else
    {
        nd->prev=tail;
        tail->next=nd;
        tail=nd;
    }
    head->prev=tail;
    tail->next=head;
}

void print(int key,int n)
{
    if(key==0)
    {
        for(int i=0;i<n;i++)
        {
            printf("0 ");
        }
        return;
    }
    
    
    if(key>0)
    {
    node *temp=head;
    int sum=0;
    do
    {
        node *temp2=temp->next;
        for(int i=0;i<key;i++)
        {
            sum+=temp2->data;
            temp2=temp2->next;
        }
        temp=temp->next;
        printf("%d ",sum);
        sum = 0;
    }while(temp!=head);
    }
    else
    {
        node *temp=head;
        int sum=0;
    do
    {
        node *temp2=temp->prev;
        for(int i=0;i<abs(key);i++)
        {
            sum+=temp2->data;
            temp2=temp2->prev;
        }
        temp=temp->prev;
        printf("%d ",sum);
        sum = 0;
    }while(temp!=head);
    }
}

void main()
{
    int n,data,key;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&data);
        create(data);
    }
    scanf("%d",&key);
    print(key,n);
}