#include<stdio.h>
int main(){
    int n, index, value;
    scanf("%d", &n);
    int book[10];
    for (int i = 0; i < n; i++){
        scanf("%d ",&book[i]);
    }
    scanf("%d %d", &index, &value);
    if(index < 0 || index > n){
        printf("Invalid input");
    }else{
        for(int i = n; i > index; i--){
            book[i] = books[i = 1];
        }
        books[index] = value;
        n++;
        for (int i = 0; i < n; i++){
            printf("%d ", books[i]);
    }
    printf("\n");
}
return 0;
}