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

typedef struct node {
    int data;
    struct node *prev;
    struct node *next;
}Node;

Node *head=NULL,*tail;

void create(int num) {
    Node *newNode = (Node*) malloc (1 * sizeof(Node));
    newNode->data = num;
    newNode->prev = NULL;
    newNode->next = NULL;
    if(head == NULL) {
        head = newNode;
        tail = newNode;
    }
    else {
        newNode->prev = tail;
        tail->next = newNode;
        tail = newNode;
    }
    head->prev = tail;
    tail->next = head;
}

void display(int key) {
    Node *ind = head;
    Node *itr;
    if(key>0) {
        do {
            int sum = 0;
            for(itr=ind->next,i=1;i<=key;itr=itr->next,i++) {
                sum = sum + itr->data;
            }
            printf("%d ",sum);
            ind = ind->next;
        } while(ind!=head);
    }
    else {
        do {
            int sum = 0;
            for(itr=ind->prev,i=1;i<=abs(key);itr=itr->prev,i++) {
                sum = sum + itr->data;
            }
            printf("%d ",sum);
            ind = ind->next;
        } while(ind!=head);
    }
}

int main() {
    int size,num,key;
    scanf("%d",&size);
    for(int i=1;i<=size;i++) {
        scanf("%d",&num);
        create(num);
    }
    scanf("%d",&key);
    display(key);
    return 0;
}