why not 3 or 4 or any other value 1…why only 2
Why loop from 2 to n-2
the loop is from 2 to <n so meaning 2 to n-1 this is because as you can see inside the loop access i+1 and i-1 so if i = 1 0 is not possible and if i=n i n+1 is not possible thats why .(same for j)
dont forget to hit like and mark resolved if cleared 
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.