Help me please! i don't know what wrong with this code

https://www.codechef.com/viewsolution/34477475

Arrays are 0 indexed in c++. If the size of your array is n, arr[n] is out of bounds.

I changed the for loop as: for(int i = 0; i < n; i++) { // code }

Still the same error “SIGTSTP” . And output is coming:
YES
YES
YES
YES

till infinity

just increase the size of the array from arr[n] to arr[n+1] , If your starting index is 1.