Help me in solving LJAJAG35 problem

My issue

Ans is right but they can’t submit and see runtime error

My code

#include <stdio.h>

int main() {
    int n, pos;

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

    if (n <= 0) {
        printf("Invalid size of the array.\n");
        return 1;
    }

    int arr[n];

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

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

    // Validate position
    if (pos < 0 || pos >= n) {
        printf("Invalid index. Please enter a valid index between 0 and %d.\n", n - 1);
        return 1;
    }

    // Delete element by shifting
    for (int i = pos; i < n - 1; i++) {
        arr[i] = arr[i + 1];
    }
    n--; // Reduce the size of the array

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

    
}

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