#include <stdio.h>
#include<stdlib.h>
#include<stdlib.h>
typedef struct node{
    int data;
    struct node *next;
    struct node *prev;
}node;
node *head=NULL,tail;
int main()
{
    int n;
    scanf("%d",&n);
    int value,i;
        for(i=0;i<n;i++){
            scanf("%d",&value);
            create(value);
        }
        scanf("%d",&value)
        display();
        return 0;
}
void create(int value){
    node *newnode=(node*)(malloc(sizeof (node)));
    newnode->data=value;
    newnode->prev=NULL;
    newnode->head=NULL;
    
    if(head==NULL){
        head=newnode;
        tail=newnode;
    }
    else(){
        newnode->prev=tail;
        tail->next=newnode;
        tail=newnode
    }
    
}
void display(int key)
{
    node* ind,itr;
    ind=head;
    if(key>0)
    {
        do{
            int sum=0,i;
            for(itr=ind->next;i<=key;itr=itr->next,i++){
                sum=sum+itr->data;
                
            }
            printf("%d",&sum);
          ind=ind->next;
    }while(ind!=head);
    return 0;
}