Help me in solving SEARCHINARR problem

My issue

even after checking for the bugs many and many times i am unable to find what is causing this code to give a runtime error . if anyone here has the solution please help me with the same .

My code

#include <stdio.h>

int main() {
    int a[10], x, n, i, found = 0;

    // Input: Number of elements and the value to search
    scanf("%d %d", &n, &x);

    // Correct the loop: Run from i = 0 to i < n (not i <= n)
    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    // Search for x in the array
    for(i = 0; i < n; i++) {
        if(a[i] == x) {
            found = 1;
            break;
        }
    }

    // Output the result based on the found flag
    if(found == 1) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}

Learning course: BCS301: Data structures
Problem Link: https://www.codechef.com/learn/course/abesit-dsa/ABESITDS06/problems/SEARCHINARR