Help me in solving LJAJAG35 problem

My issue

How runtime error

My code

#include <stdio.h>

int main() {
    int n, pos, i;

    // Get the size of the array
  
    scanf("%d", &n);

    // Declare the array
    int arr[n];

    // Get array elements
   
    for (i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    // Get the position to delete
  
    scanf("%d", &pos);

    // Check if the position is valid
    if (pos < 0 || pos >= n) {
        printf("Invalid position \n");
        return 1;
    }

    // Shift elements to the left
    for (i = pos; i < n - 1; i++) {
        arr[i] = arr[i + 1];
    }

    // Decrease the size of the array
    n--;

    // Print the modified array
   
    for (i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");

    return 0;
}

Learning course: Learn C Programming
Problem Link: https://www.codechef.com/learn/course/rcpit-programming-c/RCPITLPC37/problems/LJAJAG35