Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.

Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array a (in increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.


-----Input-----

The first line of the input contains an integer n (1 ≤ n ≤ 10^5) — the size of array a.

The second line contains n distinct space-separated integers: a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 10^9).


-----Output-----

Print "yes" or "no" (without quotes), depending on the answer.

If your answer is "yes", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.


-----Examples-----
Input
3
3 2 1

Output
yes
1 3

Input
4
2 1 3 4

Output
yes
1 2

Input
4
3 1 2 4

Output
no

Input
2
1 2

Output
yes
1 1



-----Note-----

Sample 1. You can reverse the entire array to get [1, 2, 3], which is sorted.

Sample 3. No segment can be reversed such that the array will be sorted.

Definitions

A segment [l, r] of array a is the sequence a[l], a[l + 1], ..., a[r].

If you have an array a of size n and you reverse its segment [l, r], the array will become:

a[1], a[2], ..., a[l - 2], a[l - 1], a[r], a[r - 1], ..., a[l + 1], a[l], a[r + 1], a[r + 2], ..., a[n - 1], a[n].

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = list(map(int, input().split()))

if sorted(a) == a:
    print('yes')
    print('1 1')
    return

start = 0
end = n - 1
seen = 0

for i in range(n-1):
    if not seen:
        if a[i] > a[i+1]:
            seen += 1
            start = i
    else:
        if a[i] <= a[i+1]:
            end = i
            break
#print(a)
#print(a[:start], a[start:end+1][::-1], a[end+1:], sep='\n')
a = a[:start] + a[start:end+1][::-1] + a[end+1:]
#print(a)
#print(start, end)

if sorted(a) == a:
    print('yes')
    print(start+1, end+1)
else:
    print('no')


n=int(input())
a=list(map(int,input().split()))
s=a.copy()
s.sort()
if a==s:
    print("yes\n1 1")
else:
    _First=-1
    _Last=-1
    for i,x in enumerate(a):
        if s[i]!=x:
            if _First==-1:
                _First=i
            _Last=i
    __First=_First
    __Last=_Last
    _b=True
    while __First<=_Last and __Last>=_First:
        if a[__First]==s[__Last]:
            pass
        else:
            _b=False
        __First+=1
        __Last-=1
    if _b:
        print("yes")
        print(str(_First+1),str(_Last+1))
    else:
        print("no")

n = int(input())
a = list(map(int, input().split()))
phase = 0
l = -1
r = -1
for i in range(1, len(a)):
    g = a[i] > a[i-1]
    if phase == 0 and not g:
        l = i
        phase = 1
    if phase == 1 and g:
        r = i
        phase = 2
    if phase == 2 and not g:
        print('no')
        return
if phase == 0:
    print('yes')
    print('1 1')
    return
elif phase == 1:
    r = len(a)
cur = -1
f = True
for i in range(0, l-1):
    if a[i] < cur:
        f = False
        break
    cur = a[i]
for i in range(r-1, l-2, -1):
    if a[i] < cur:
        f = False
        break
    cur = a[i]
for i in range(r, len(a)):
    if a[i] < cur:
        f = False
        break
    cur = a[i]
if f:
    print('yes')
    print(l, r)
else:
    print('no')


N = int(input())
a = list(map(int, input().split()))

pos_L = -1
for i in range(1, len(a)):
    if a[i] < a[i - 1]:
        pos_L = i - 1
        break

if pos_L == -1:
    print('yes')
    print('1 1')
    return

pos_R = -1;
for i in range(len(a) - 1, 0, -1):
    if a[i] < a[i - 1]:
        pos_R = i
        break

if pos_R == -1:
    print('yes')
    print(1, N)
    return

half_len = (pos_R - pos_L + 1) // 2
for i in range(pos_L, pos_L + half_len):
    a[i], a[pos_R + pos_L - i] = a[pos_R + pos_L - i], a[i];

for i in range(1, len(a)):
    if a[i] < a[i - 1]:
        print('no')
        return

print('yes')
print(pos_L + 1, pos_R + 1)


sa=int(input())
sa2=input().split(' ')
nums=[int(x) for x in sa2]
diffs=[nums[x+1]-nums[x] for x in range(sa-1)]

listx=[x for x in range(sa-1) if diffs[x]<0]

if listx==[]:
    print("yes")
    print("1 1")
else:
    magic=nums[listx[0]:listx[-1]+2]
    magic.reverse()
    nums[listx[0]:listx[-1]+2]=magic

    mark=0
    for t in range(sa-1):
        if nums[t]-nums[t+1]>0:
            mark=1
    if mark==1:
        print("no")
    else:
        print("yes")
        print(listx[0]+1, listx[-1]+2)


def isSorted(l):
    i = 1
    while i < len(l):
        if l[i] < l[i-1]:
            return False
        i += 1
    return True
n = int(input())
a = list(map(int,input().split()))
s = e = 0
i = 1
b = list()
while i < len(a):
    if a[i] > a[i-1]:
        i += 1
    else:
        s = i-1
        while i < n and a[i] < a[i-1]:
            i+=1
        e = i-1
        b = a[0:s] + list(reversed(a[s:e+1])) + a[e+1:]
      
        break
if isSorted(b):
    print('yes')
    print(s+1,e+1,sep=' ')
else:
    print('no')


n = int(input())
A = list(map(int, input().split()))
sA = sorted(A)

pa = 1
while pa <= n and A[pa - 1] == sA[pa - 1]:
    pa = pa + 1

if pa == n + 1:
    print('yes\n1 1')
else:
    pb = n
    while pb >= 1 and A[pb - 1] == sA[pb - 1]:
        pb = pb - 1
    
    AB = A[pa - 1:pb]
    rAB = reversed(AB)
    sAB = sA[pa - 1:pb]
    can = sum(1 for (x, y) in zip(sAB, rAB) if x != y)
    if can == 0:
        print('yes')
        print(pa, pb)
    else:
        print('no')


n=input()
thelist=input()
final=[]
now=thelist.split()
for item in now:
    final.append(int(item))
begin=sorted(final)
indices=[]
i=0
length=len(final)
while i<length:
    if final[i] != begin[i]:
        indices.append(i)
    i+=1
all=len(indices)
if len(indices) !=0:
    x=indices[0]
    y=indices[all-1]
    switched=[]
    p=0
    while p<x:
        switched.append(final[p])
        p+=1
    j=0
    while j<= (y-x):
        switched.append(final[y-j])
        j+=1
    q=y+1
    while q<length:
        switched.append(final[q])
        q+=1
    switchable="yes"
    z=0
    while z<len(begin):
        if switched[z] != begin[z]:
            switchable="no"
            break
        z+=1
    if switchable=="yes":
        print("yes")
        print(x+1,y+1)
    else:
        print("no")

else:
    print("yes")
    print("1 1")



__author__ = 'Gleb'
n=int(input())
a=input().split()
isna=[]
for i in range(n):
    a[i]=int(a[i])
    isna.append(a[i])



a.sort()
i=0
while (i<n)and(isna[i]==a[i]):
    i+=1
nach=i
if i==n:
    print('yes')
    print(1,1)
else:
    nache=isna[i]
    while (i<n)and not(a[i]==nache):
        i+=1
    kon=i
    b=isna[0:nach]
    for i in range(kon,nach-1,-1):
        b.append(isna[i])
    b+=isna[kon+1:n]


    if b==a:
       print('yes')
       print(nach+1,kon+1)
    else:
       print('no')


def reverse(arr, left, right):
    while left < right:
        t = arr[left]
        arr[left] = arr[right]
        arr[right] = t
        left += 1
        right -= 1

n = int(input())
a = list(map(int, input().split()))
b = a.copy()
b.sort()
left = -1
right = -1
for i in range(n):
    if a[i] != b[i]:
        left = i
        break
if left == -1:
    print("yes")
    print(1, 1)
    return
for i in range(n - 1, -1, -1):
    if a[i] != b[i]:
        right = i
        break
reverse(a, left, right)
for i in range(n):
    if a[i] != b[i]:
        print("no")
        return
print("yes")
print(left + 1, right + 1)


def solve():
    n = int(input())
    a = list(map(int,input().split()))
    left,right = 0,0
    for i in range(n-1):
        if a[i] > a[i+1]:
            left = i
            break
    for i in range(n-1):
        if a[i] > a[i+1]:
            right = i+1
    t = sorted(a)
    a[left:right+1] = reversed (a[left:right+1])
    print('yes\n',left+1, right+1) if(a == t) else print('no\n')
solve()

3

def _reverse(arr, left, right):
    n = len(arr)
    return arr[:left] + arr[-n+right:-n+left-1:-1] + arr[right+1:]

def check(arr):
    n = len(arr)
    for i in range(1, n):
        if arr[i] < arr[i-1]:
            return False
    return True

t = int(input())
arr = [[-1*10**10, 0], [-1*10**10+1, 1]]
val = []
_number = 2
for i in input().split():
    val.append(int(i))
    arr.append([int(i), _number])
    _number += 1

arr.append([10**10, t+2])
arr.append([10**10+1, t+3])
t += 4

if check(val):
    print("yes\n1 1")
    return

arr.sort()

left = 1
for i in range(1, t):
    if arr[i-1][1]+1 == arr[i][1]:
        left = i
    else:
        break
right = t-2
for i in range(t-2, 0, -1):
    if arr[i+1][1]-1 == arr[i][1]:
        right = i
    else:
        break

left, right = arr[right-1][1]-2, arr[left+1][1]-2

flag = False
if left <= right:
    val = _reverse(val, left, right)
    flag = check(val)

if not flag:
    print('no')
else:
    print("yes\n%d %d" % (left+1, right+1))

n = int(input())
a = list(map(int,input().split()))

a_sort = list(a)
a_sort.sort()
#print(a_sort)

index = []

for i in range(n):
    if a[i] != a_sort[i]:
        index.append(i)
if len(index) == 0 :
    print("yes")
    print("1 1")
else:
    section = []
    for i in range(index[0],index[-1]+1,1):
        section.append(a[i])
    #print(section)
    section_rev = [0]*len(section)
    #print(index)
    for i in range(len(section)):
        section_rev[len(section)-1-i] = section[i]
    #print(section_rev)
    x = 0
    for i in range(index[0],index[-1]+1):
        #print(a[i], section_rev[x])
        a[i] = section_rev[x]
        x += 1
    #print(a)
    out = True
    for i in range(n):
        if a[i] != a_sort[i]:
            out = False
            break
    if out:
        print("yes")
        print(index[0]+1,index[-1]+1)
    else:
        print("no")


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(a[i])
b.sort()
f = -1
l = 0
for i in range(n):
    if a[i] != b[i]:
        if f == -1:
            f = i
        l = i
if f != -1:
    c = a[:f]
    if f != 0:
        c += a[l:f - 1:-1] 
    else:
        c += a[l::-1] 
        
    c += a[l + 1:]
else:
    f = 0
    c = a
flag = True
for i in range(n):
    if b[i] != c[i]:
        flag = False
if flag:
    print('yes')
    print(f + 1, l + 1)
else:
    print('no')

    


n = int(input())
a = list(map(int, input().split()))

def Reverse(a, l, r):
  i, j = l, r
  while i < j:
    a[i], a[j] = a[j], a[i]
    i += 1
    j -= 1

def IsSorted(a):
  for i in range(n - 1):
    if a[i] > a[i + 1]:
      return False
  return True

for l in range(n - 1):
  if a[l] > a[l + 1]:
    r = l + 1
    while r + 1 < n and a[r] > a[r + 1]:
      r += 1
    Reverse(a, l, r)
    if IsSorted(a):
      print("yes")
      print(l + 1, r + 1)
    else:
      print("no")
    break
else:
  print("yes")
  print(1, 1)

def decSeq(L):
    l, r = 0, 0
    for i in range(len(L)-1):
        if L[i+1] < L[i]:
            l = i
            break
    try:
        for i in range(l, len(L)):
            r = i
            if L[i+1] > L[i]:
                break
    except IndexError:
        r = len(L)-1
    return l, r

n, arr = input(), list(map(int, input().split()))

l, r = decSeq(arr)

if sorted(arr) == arr:
    print('yes')
    print(1,1)
elif sorted(arr) == arr[:l] + sorted(arr[l:r+1]) + arr[r+1:]:
    print('yes')
    print(l + 1, r + 1)
else:
    print('no')

n = int(input())
numbers = [int(i) for i in input().split()]
i = 1
while i < len(numbers) and numbers[i] >= numbers[i - 1]:
    i += 1
j = len(numbers) - 1
while j > 0 and numbers[j] >= numbers[j - 1]:
    j -= 1
i -= 1
if not j:
    print('yes')
    print(1, 1)
else:
    rev = numbers[i: j + 1]
    rev.reverse()
    sd = numbers[:i] + rev + numbers[j + 1:]
    if  sd == sorted(numbers):
        print('yes')
        print(i + 1, j + 1)
    else:
        print('no')

n = int(input())
t = list(map(int, input().split()))
p = sorted(t)
a = b = 0
for i in range(n): 
    if t[i] != p[i]: 
        a, b = i, n - 1
        while t[b] == p[b]: b -= 1
        break
b += 1
print('yes\n' + str(a + 1) + ' ' + str(b) if t[a: b] == p[a: b][:: -1] else 'no')

import sys

n = input().split()[0]
n = (int)(n)
alist = input().split()

alist.insert(0,-1)
alist.append(1e9 + 1)
#print (alist)
#print (len(alist))

ans = 1
flag1 = flag2 = -1
n = n + 2
for i in range(n-1):
	if (int)(alist [i]) > (int)(alist [i+1]) :
		flag1 = i
		break
	else :
		continue

#print (flag1)
if flag1 == -1:
	print ("yes\n1 1\n")
	return

for i in range(flag1+1,n-1) :
	if (int)(alist[i]) < (int)(alist [i+1]) :
		flag2 = i
		break
	else :
		continue
#print (flag2)
if flag2 == -1:
	print ("yes\n%d %d\n"%(flag1+1,n-1))
	return

for i in range(flag2+1,n-1):
	if (int)(alist[i]) > (int)(alist[i+1]):
		print("no\n")
		return

#print("here！")

if ((int)(alist[flag2]) < (int)(alist[flag1-1])) or ((int)(alist[flag1]) > (int)(alist[flag2+1])) :
	print("no\n")
	return

print("yes\n%d %d\n"%(flag1,flag2))

def issort(a):
    for k in range(len(a)-1):
        if a[k]>a[k+1]:
            return False
    return True
n=int(input())
a=list(map(int,input().split()))
i,j=0,n-1
while i<n-1 and a[i]<a[i+1]:
    i+=1
while j>0 and a[j]>a[j-1]:
    j-=1
if j==0:
    print('yes')
    print(j+1,j+1)
else:
    if issort(a[:i]+a[i:j+1][::-1]+a[j+1:]):
        print('yes')
        print(i+1,j+1)
    else:
        print('no')

n = int(input())
a = list(input().split())
i = 0
while i<n :
    a[i] = int(a[i])
    i = i+1
b,i = True,1
while i<n :
    if a[i-1]>=a[i] :
        b = False
        break
    i = i+1
if b :
    print('yes')
    print('1 1')
else :
    i = 1
    while a[i-1]<a[i] :
        i = i+1
    p = i-2
    while i<n and a[i-1]>a[i] : 
        i = i+1
    q = i
    while i<n and a[i-1]<a[i] : 
        i = i+1
    if i!=n :
        print('no')
    else :
        if p==-1 and q==n :
            print('yes')
            print(1,n)
        elif p==-1 :
            if a[0]<a[q] :
                print('yes')
                print(1,q)
            else :
                print('no')
        elif q==n :
            if a[p]<a[n-1] :
                print('yes')
                print(p+2,n)
            else :
                print('no')
        else :
            if a[p+1]<a[q] and a[p]<a[q-1] :
                print('yes')
                print(p+2,q)
            else :
                print('no')


def indeksTurun(a):
	for x in range(len(a)-1):
		if a[x] > a[x+1]:
			return x+1
			pass
		pass
	return -1
	pass

def menaik(a,i1):
	for x in range(i1,len(a)-1):
		if a[x] > a[x+1]:
			return False
			pass
		pass
	return True
	pass

a=input()
a=list(map(int,input().split(" ")))

if len(a) == 1:
	print ("yes")
	print ("1 1")
else:
	reversed_indeks1=-1
	for x in range(len(a)-1):
		if a[x] > a[x+1]:
			reversed_indeks1=x
			break
			pass
		pass
	if reversed_indeks1 == -1:
		print ("yes")
		print ("1 1")
	else:
		reversed_indeks2=len(a)-1
		for x in range(reversed_indeks1,len(a)-1):
			if a[x] < a[x+1]:
				reversed_indeks2=x
				break
		asc=True
		if reversed_indeks2 != len(a)-1:
			asc=menaik(a,reversed_indeks2+1)
		if asc:
			kiri=True
			kanan=True
			if reversed_indeks1 != 0:
				if a[reversed_indeks2] < a[reversed_indeks1-1]:
					kiri=False
					pass
			if reversed_indeks2 != len(a)-1:
				if a[reversed_indeks1] > a[reversed_indeks2+1]:
					kanan=False
					pass
				pass
				pass
			if kiri and kanan:
				print ("yes")
				print ("%d %d"%(reversed_indeks1+1,reversed_indeks2+1))
				pass
			else:
				print ("no")
		else:
			print ("no")
			pass
	pass