Change line no 8 of your code as, if(a[0]<=a[1] && print(n-1,a+1)){ and then try to submit your code…