Help me in solving SEARCHINARR problem

My issue

What is the problem here?

My code

#include <stdio.h>

int main() 
{
    int a[20],n,i,b;
    scanf("%d", &n);
    scanf("%d", &b);
    for(i=0;i<n;i++)
        {
            scanf("%d", &a[i]);
        }
    for(i=0;i<n;i++)
    {    
        if (a[b]==a[i])
        {
            printf("YES");
        }
    }
    return 0;
}

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

#include <stdio.h>

int main() 
{
    int a[20], n, i, b;
    scanf("%d", &n);
    scanf("%d", &b);

    // Check if b is within the valid range
    if (b >= n) {
        printf("Index out of bounds\n");
        return 1;
    }

    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    int found = 0; // Flag to check if the element is found
    for (i = 0; i < n; i++) {    
        if (a[b] == a[i]) {
            found = 1;
            break; // Exit the loop once the element is found
        }
    }

    if (found) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}