Need help ON COVID duty

[The problem → Covid patient count] (COVID19 Problem - CodeChef)

My solution was partially corrected I think on some test cases my code is not getting the required output . Please help to debug my code

My code

for every xi you have to check number of people ,the person at xi can affect
and simply count them
then find minimum and maximum among them
below is implementation my approach
https://www.codechef.com/viewsolution/49450446
for example
5
1 2 5 6 7

person at i==0 infect 1,2
person at i==1 infect 2 ,1
person at i==2 infect 5,6,7
person at i==3 infect 6,5,7
person at i==4 infect 7,6,5
min=2;
max=3;