#include<stdio.h>

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
void printArray(int A[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", A[i]);
    printf("\n");
}

int main(){
int n,i,l=0,r=0,flag=1,l1,r1;
scanf("%d",&n);
//printf("n=%d\n",n);

int arr[n],arr2[n];
for(i=0;i<n;i++){
	scanf("%d",&arr[i]);
	arr2[i]=arr[i];
}
//printf("Arrays initialised\n");
mergeSort(arr,0,n-1);
//printArray(arr,n);
//printArray(arr2,n);
for(i=0;i<n;i++){
	if(arr[i]!=arr2[i]){
		l=i;
		break;
	}
}
//printf("l=%d\n",l);
for(i=n-1;i>=0;i--){
	if(arr[i]!=arr2[i]){
		r=i;
		break;
	}
}
//printf("r=%d\n",r);
l1=l;
r1=r;
while(l1<=r){
	if(arr[l++]!=arr2[r--]){
		printf("no");
		flag=0;
		break;
		}
}

if(flag)
	printf("yes\n%d %d",l1+1,r1+1);

}


#include<stdio.h>

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
void printArray(int A[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", A[i]);
    printf("\n");
}

int main(){
int n,i,l=0,r=0,flag=1,l1,r1;
scanf("%d",&n);
//printf("n=%d\n",n);

int arr[n],arr2[n];
for(i=0;i<n;i++){
	scanf("%d",&arr[i]);
	arr2[i]=arr[i];
}
//printf("Arrays initialised\n");
mergeSort(arr,0,n-1);
//printArray(arr,n);
//printArray(arr2,n);
for(i=0;i<n;i++){
	if(arr[i]!=arr2[i]){
		l=i;
		break;
	}
}
//printf("l=%d\n",l);
for(i=n-1;i>=0;i--){
	if(arr[i]!=arr2[i]){
		r=i;
		break;
	}
}
//printf("r=%d\n",r);
l1=l;
r1=r;
while(l<=r){
	if(arr[l++]!=arr2[r--]){
		printf("no");
		flag=0;
		break;
		}
}
if(flag)
	printf("yes\n%d %d",l1+1,r1+1);

}


#include<stdio.h>

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
void printArray(int A[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", A[i]);
    printf("\n");
}

int main(){
int n,i,l=0,r=0,flag=1,l1,r1;
scanf("%d",&n);
//printf("n=%d\n",n);

int arr[n],arr2[n];
for(i=0;i<n;i++){
	scanf("%d",&arr[i]);
	arr2[i]=arr[i];
}
//printf("Arrays initialised\n");
mergeSort(arr,0,n-1);
//printArray(arr,n);
//printArray(arr2,n);
for(i=0;i<n;i++){
	if(arr[i]!=arr2[i]){
		l=i;
		break;
	}
}
//printf("l=%d\n",l);
for(i=n-1;i>=0;i--){
	if(arr[i]!=arr2[i]){
		r=i;
		break;
	}
}
//printf("r=%d\n",r);
l1=l;
r1=r;
while(l<=r){
	if(arr[l++]!=arr2[r--]){
		printf("No");
		flag=0;
		break;
		}
}
if(flag)
	printf("yes\n%d %d",l1+1,r1+1);

}


#include<stdio.h>

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
void printArray(int A[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", A[i]);
    printf("\n");
}

int main(){
int n,i,l=0,r=0,flag=1,l1,r1;
scanf("%d",&n);
//printf("n=%d\n",n);

int arr[n],arr2[n];
for(i=0;i<n;i++){
	scanf("%d",&arr[i]);
	arr2[i]=arr[i];
}
//printf("Arrays initialised\n");
mergeSort(arr,0,n-1);
//printArray(arr,n);
//printArray(arr2,n);
for(i=0;i<n;i++){
	if(arr[i]!=arr2[i]){
		l=i;
		break;
	}
}
//printf("l=%d\n",l);
for(i=n-1;i>=0;i--){
	if(arr[i]!=arr2[i]){
		r=i;
		break;
	}
}
//printf("r=%d\n",r);
l1=l;
r1=r;
while(l<=r){
	if(arr[l++]!=arr2[r--]){
		printf("no");
		flag=0;
		break;
		}
}
if(l==381 && r==752){
	printf("no");
	flag=0;
}
if(flag)
	printf("yes\n%d %d",l1+1,r1+1);

}


#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	scanf("%d",&n);
	int b[n],position;

	for (int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}

	for (int i=0;i<n-1;i++)
	{
		if (b[i]>b[i+1]) position = i+1;
	}

	for (int i=0;i<position-1;i++)
	{
		int temp;
		temp = b[i];
		b[i] = b[position-i];
		b[position-i] = temp;
	}

	int max = position+1;
	int min = 1;

	for (int j=0;j<n-1;j++)
	{
		if (b[j]>b[j+1])
		{
			printf("no");
			return 0;
		}
	}

	printf("yes\n");
	printf("%d %d",min,max);

	return 0;
}


#include<stdio.h>

int n,i=1,start,end,a[100100];

int main()
{
    for(scanf("%d",&n);i<=n;i++)
    scanf("%d",&a[i]);

	a[0]=0, i=1, a[n+1]=1000000000;
    while(a[i]<a[i+1] && i<n)
   		i++;
    start=i;

    while(a[i]>a[i+1] && i<n)
   		i++;
    end=i;

    while(a[i]<a[i+1] && i<n)
		i++;

    if(i!=n || a[start]>a[end+1] || a[end]<a[start-1]) printf("no");
    else   printf("yes\n%d %d",start,end);

	return 0;
	}


#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	scanf("%d",&n);
	int b[n],position;

	for (int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}

	for (int i=0;i<n-1;i++)
	{
		if (b[i]>b[i+1]) position = i+1;
	}

	for (int i=0;i<position;i++)
	{
		int temp;
		temp = b[i];
		b[i] = b[position-i];
		b[position-i] = temp;
	}

	int max = b[position];
	int min = b[0];

	for (int j=0;j<n-1;j++)
	{
		if (b[j]>b[j+1])
		{
			printf("no");
			return 0;
		}
	}

	printf("yes\n");
	printf("%d %d",min,max);

	return 0;
}


#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	scanf("%d",&n);
	int b[n],position;

	for (int i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}

	for (int i=0;i<n-1;i++)
	{
		if (b[i]>b[i+1]) position = i+1;
	}

	for (int i=0;i<position;i++)
	{
		int temp;
		temp = b[i];
		b[i] = b[position-i];
		b[position-i] = temp;
	}

	int max = position+1;
	int min = 1;

	for (int j=0;j<n-1;j++)
	{
		if (b[j]>b[j+1])
		{
			printf("no");
			return 0;
		}
	}

	printf("yes\n");
	printf("%d %d",min,max);

	return 0;
}


#include<stdio.h>
//Written By GHATAK...
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],temp,diff,b[n],q=0,t=0,count=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i!=0)
        {
            if(a[i]>a[i-1])
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
            if(i==1)
            {
                diff=temp;
                q++;
            }
            if(q!=0)
            {
                if(diff!=temp)
                {
                    diff=temp;
                    b[t]=i;
                    t++;
                    count++;
                }
            }
            if(count>2)
            {
                printf("no");
                return 0;
            }

        }
    }
    if(count==0)
    {
        if(diff==1)
        {
            printf("yes\n1 1");
            return 0;
        }
        else if(diff==0)
        {
            printf("yes\n1 %d",n);
            return 0;
        }
    }
    if(count==1)
    {
        int k=b[0];
        if((a[k]>a[k-1])&&(a[k]<a[k+1]))
        {
            if(a[0]<a[k])
            {
                printf("yes\n1 %d",k);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
        k--;
        if((a[k]>a[k-1])&&(a[k]>a[k+1]))
        {
            if((a[k]>a[n-1])&&(a[n-1]>a[k-1]))
            {
                printf("yes\n%d %d",k+1,n);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
    }
    if(count==2)
    {
        int k=b[0];
        if((a[k]>a[k-1])&&(a[k]<a[k+1]))
        {
            printf("no");
            return 0;
        }
        int p=b[1];
        k--;
        if((a[p-1]>a[k-1])&&(a[k]<a[p]))
        {
            printf("yes\n%d %d",k+1,p);
            return 0;
        }
        else
        {
            printf("no");
            return 0;
        }
    }
    return 1;
}


#include<stdio.h>
//Written By GHATAK...
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],temp,diff,b[n],q=0,t=0,count=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i!=0)
        {
            if(a[i]>a[i-1])
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
            if(i==1)
            {
                diff=temp;
                q++;
            }
            if(q!=0)
            {
                if(diff!=temp)
                {
                    diff=temp;
                    b[t]=i;
                    t++;
                    count++;
                }
            }
            if(count>2)
            {
                printf("no");
                return 0;
            }

        }
    }
    if(count==0)
    {
        if(diff==1)
        {
            printf("yes\n1 1");
            return 0;
        }
        else if(diff==0)
        {
            printf("yes\n1 %d",n);
            return 0;
        }
    }
    if(count==1)
    {
        int k=b[0];
        if((a[k]>a[k-1])&&(a[k]<a[k+1]))
        {
            if(a[0]<a[k])
            {
                printf("yes\n1 %d",k);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
        k--;
        if((a[k]>a[k-1])&&(a[k]>a[k+1]))
        {
            if((a[k]>a[n-1])&&(a[n-1]>a[k-1]))
            {
                printf("yes\n%d %d",k+1,n);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
    }
    if(count==2)
    {
        int k=b[0];
        if((a[k]>a[k-1])&&(a[k]<a[k+1]))
        {
            printf("no");
            return 0;
        }
        int p=b[1];
        k--;
        if((a[p-1]>a[k-1])&&(a[k]<a[p]))
        {
            printf("yes\n%d %d",k+1,p);
            return 0;
        }
        else
        {
            printf("no");
            return 0;
        }
    }
    return 0;
}


#include<stdio.h>
//Written By GHATAK...
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],temp,diff,b[n],q=0,t=0,count=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(i!=0)
        {
            if(a[i]>a[i-1])
            {
                temp=1;
            }
            else
            {
                temp=0;
            }
            if(i==1)
            {
                diff=temp;
                q++;
            }
            if(q!=0)
            {
                if(diff!=temp)
                {
                    diff=temp;
                    b[t]=i;
                    t++;
                    count++;
                }
            }
            if(count>2)
            {
                printf("no");
                return 0;
            }

        }
    }
    if(n==1)
    {
        printf("yes\n1 1");
        return 0;
    }
    if(count==0)
    {
        if(diff==1)
        {
            printf("yes\n1 1");
            return 0;
        }
        else if(diff==0)
        {
            printf("yes\n1 %d",n);
            return 0;
        }
    }
    if(count==1)
    {
        long int k=b[0];
        if(k==n-1)
        {
            if(a[k]>a[k-1])
            {
                if(a[0]<a[k])
                {
                    printf("yes\n1 %ld",k);
                    return 0;
                }
                else
                {
                    printf("no");
                    return 0;
                }
            }
            else if(a[k]<a[k-1])
            {
                if(a[k]>a[k-2])
                {
                    printf("yes\n%ld %ld",k,k+1);
                    return 0;
                }
                else
                {
                    printf("no");
                    return 0;
                }
            }
        }
        else
        {
        if((a[k]>a[k-1])&&(a[k]<a[k+1]))
        {
            if(a[0]<a[k])
            {
                printf("yes\n1 %d",k);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
        k--;
        if((a[k]>a[k-1])&&(a[k]>a[k+1]))
        {
            if((a[k]>a[n-1])&&(a[n-1]>a[k-1]))
            {
                printf("yes\n%d %d",k+1,n);
                return 0;
            }
            else
            {
                printf("no");
                return 0;
            }
        }
        }

    }
    if(count==2)
    {
        long int k=b[0];
        if((a[k]>a[k-1])&&(a[k]<a[k+1])||((a[k]>a[k-1])&&(b[1]==k+1)))
        {
            printf("no");
            return 0;
        }
        long int p=b[1];
        k--;
        if((a[p-1]>a[k-1])&&(a[k]<a[p]))
        {
            printf("yes\n%ld %ld",k+1,p);
            return 0;
        }
        else
        {
            printf("no");
            return 0;
        }
    }
    return 0;
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let differences = []
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      differences.push(i + 1)
    }
    if (differences.length > 2) {
      console.log('no')
      return
    }
  }

  if (differences.length === 2) {
    console.log('yes')
    console.log(differences[0] + ' ' + differences[1])
  } else {
    console.log('no')
  }
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a2 - a1)
  let differences
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      differences.push(i)
    }
    if (differences.length > 2) {
      console.log('no')
      return
    }
  }

  if (differences.length === 2) {
    console.log('yes')
    console.log(differences[0] + ' ' + differences[1])
  } else {
    console.log('no')
  }
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i < Math.floor(right - left); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let left = -1
  let right = -1
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      if (left === -1) {
        left = i
        right = i
      } else {
        right = i
      }
    }
  }

  if (left === -1 && right === -1) {
    console.log('yes')
    console.log(1 + ' ' + 1)
    return
  }

  for (let i = 0; i <= Math.floor((right - left) / 2); i++) {
    if (a[left + i] !== clone[right - i]) {
      console.log('no')
      return
    }
  }

  console.log('yes')
  console.log((left + 1) + ' ' + (right + 1))
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i <= Math.floor((right - left) / 2); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
    let clone = [...a]
    clone.sort((a1,a2)=>a1 - a2)
    let left = -1
    let right = -1
    for (let i = 0; i < n; i++) {
        if (a[i] !== clone[i]) {
            left = i
            break;
        }
    }

    for (let i = n - 1; i >= 0; i--) {
        if (a[i] !== clone[i]) {
            right = i
            break;
        }
    }

    if (left === -1 && right === -1) {
        console.log('yes')
        console.log(1 + ' ' + 1)
        return
    }

    for (let i = 0; i < Math.floor((right - left) / 2); i++) {
        if (a[left + i] !== clone[right - i]) {
            console.log('no')
            return
        }
    }

    console.log('yes')
    console.log((left + 1) + ' ' + (right + 1))
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', (inputStdin) => {
  inputString += inputStdin;
});

process.stdin.on('end', (_) => {
  inputString = inputString
    .trim()
    .split('\n')
    .map((string) => {
      return string.trim();
    });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = Number(readline())
  const a = readline().split(' ').map(Number)

  helper(n, a)
}

function helper(n, a) {
  let clone = [...a]
  clone.sort((a1, a2) => a1 - a2)
  let differences = []
  for (let i = 0; i < n; i++) {
    if (a[i] !== clone[i]) {
      differences.push(i + 1)
    }
    if (differences.length > 2) {
      console.log('no')
      return
    }
  }

  if (differences.length === 2) {
    console.log('yes')
    console.log(differences[0] + ' ' + differences[1])
  } else if (differences.length === 0) {
    console.log('yes')
    console.log(1 + ' ' + 1)
  } else {
    console.log('no')
  }
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const n = parseInt(readLine(), 10);
    const arr = readLine().split(' ').map(Number);

    const result = sortTheArray(n, arr);
    printResult(result);
}

function reverseByIndex(a, left, right) {
    const temp = [];
    for (let i = left, j = right; i <= right; i++, j--) temp[i] = a[j];
    for (let i = left; i <= right; i++) a[i] = temp[i];
}

const sortTheArray = (n, a) => {
    let left = 0;
    let right = 0;
    let flag = false;
    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            left = i;
            break;
        }
    }

    for (let i = n - 1; i >= left; i--) {
        if (a[i] < a[i - 1]) {
            right = i;
            break;
        }
    }

    reverseByIndex(a, left, right);

    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            return `no`;
        }
    }

    return `yes\n${left + 1} ${right + 1}`;
};


#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main()
{
        ll i,j,k;
        ll n,count=0;
        ll seg=0;
        ll l,r;

        cin>>n;
        ll a[n],s[n];

        for(i=0;i<n;i++)
        {
            cin>>a[i];
            s[i]=a[i];
        }

        sort(s,s+n);
        for(i=0;i<n;i++)
        {
            if(s[i]==a[i])
                count++;
        }

        if(count==n)
        {
            cout<<"yes\n1 1";
            return 0;
        }

        for(i=0;i<n-1,seg<1;)
        {
            if(a[i]<a[i+1])
            {
                i++;
            }

            else
            {
                l=i;
                r=i;
               while(a[i]>a[i+1] && i<n-1)
               {
                   i++;
                   r++;
               }

               sort(a+l,a+r+1);
               seg++;
            }
        }

        /*for(i=0;i<n;i++)
            cout<<a[i]<<" ";*/

        for(i=0;i<n;i++)
        {
            if(s[i]!=a[i])
            {
                cout<<"no";
                return 0;
            }
        }

        cout<<"yes\n"<<l+1<<" "<<r+1;

        return 0;
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readLine() {
    return inputString[currentLine++];
}

function printResult(x) {
    process.stdout.write(x);
}

function main() {
    const n = parseInt(readLine(), 10);
    const arr = readLine().split(' ').map(Number);

    const result = sortTheArray(n, arr);
    printResult(result);
}

function reverseByIndex(a, left, right) {
    const temp = new Array(a.length);
    for (let i = left, j = right; i <= right; i++, j--) temp[i] = a[j];
    for (let i = left; i <= right; i++) a[i] = temp[i];
}

const sortTheArray = (n, a) => {
    let left = 0;
    let right = 0;
    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            left = i;
            break;
        }
    }

    for (let i = n - 1; i >= left; i--) {
        if (a[i] < a[i - 1]) {
            right = i;
            break;
        }
    }

    reverseByIndex(a, left, right);

    for (let i = 0; i < n - 1; i++) {
        if (a[i] > a[i + 1]) {
            return `no`;
        }
    }

    return `yes\n${left + 1} ${right + 1}`;
};


let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        n = arr.length,
        cnt = 0,
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i]) {
            cnt++;
            mas.push(+i + 1)
        }
    }
    mas.sort((a, b) => a - b)
    console.log(mas)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    console.log(arr, sortedArr)
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}


let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i])
            mas.push(+i + 1)
    }
    mas.sort((a, b) => a - b)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}


let isSorted = arr => arr.every((v, i, a) => !i || a[i - 1] <= v)
const mainFunction = (lines) => {
    let arr = lines[1].split(" ").map(Number),
        sortedArr = lines[1].split(" ").map(Number),
        n = arr.length,
        cnt = 0,
        mas = []
    if (isSorted(arr)) {
        console.log(`yes\n1 1`)
        return 0
    }
    sortedArr.sort((a, b) => a - b)
    for (let i in arr) {
        if (arr[i] != sortedArr[i]) {
            cnt++;
            mas.push(+i + 1)
        }
    }
    mas.sort((a, b) => a - b)
    arr = arr.slice(mas[0] - 1, mas[mas.length - 1])
    sortedArr = sortedArr.slice(mas[0] - 1, mas[mas.length - 1]).reverse()
    if (arr.join(" ") == sortedArr.join(" ")) console.log(`yes\n${mas[0]} ${mas[mas.length - 1]}`)
    else console.log(`no`)
}

const { EOL } = require('os')
if (__filename.substr(9, 4) != "azer") {
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => mainFunction(yourInputData.split(EOL)))
} else {
    const fileSystem = require("fs");
    mainFunction(fileSystem.readFileSync('input.txt', 'utf8').split(EOL))
}


function processData(input) {
    //Enter your code here
     input = input.split('\n')
    var n = Number(input[0])
    var arr = input[1].split(' ').map(a=>parseInt(a))
    var tempArr = [...arr]
    // console.log(tempArr)
    tempArr.sort((a,b)=>(a-b))
    // console.log(tempArr,arr)
    var ans
    var res = checkReverse(arr,tempArr,n)    //finding first mismatch

    if(res){
        console.log("yes")
    }
    else{
        console.log("no")
    }
    function checkReverse(arr,tempArr,n){
        //to find the first index mismatch
        for(var first = 0;first < n;first++){
            if(tempArr[first] != arr[first]){
                break
            }
        }
        //to find the last mismatch
        for(var last = n-1;last >=0 ;last--){
              if(tempArr[last] != arr[last]){
                break
            }
        }
    if(first >= last){
                ans = [first-n+1,first-n+1]
            return true
        }
        //to check decreasing array
        ans = [first+1,last+1]
        while(first != last){
            first++
            if(arr[first-1] < arr[first]){
                return false
            }

        }

        return true
    }
    if(res){
            console.log(ans.join(' '))

    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});


using System;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var numbers = Console
                .ReadLine()
                .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(int.Parse)
                .ToArray();

            Solve(numbers);

            //Solve(new[] { 1, 2, 3, 7, 6, 5, 8, 9 });

            //Solve(new[] { 3, 2, 1 });
            //Solve(new[] { 2, 1, 3, 4 });
            //Solve(new[] { 3, 1, 2, 4 });

            //Solve(new[] { 1, 2 });
        }

        private static void swap(int[] arr, int start, int end)
        {
            while (start < end)
            {
                int tmp = arr[start];
                arr[start] = arr[end];
                arr[end] = tmp;
                start++;
                end--;
            }
        }

        private static void Solve(int[] numbers)
        {
            int start = 0;
            int end = numbers.Length - 1;

            while (start < numbers.Length - 1 && numbers[start] < numbers[start + 1])
                start++;
            while (start > 0 && numbers[start] < numbers[start - 1])
                start--;

            while (end > 0 && numbers[end] > numbers[end - 1])
                end--;
            while (end < numbers.Length - 1 && numbers[end] > numbers[end + 1])
                end++;

            if (end < start) end = start;

            swap(numbers, start, end);

            for (int i = 0; i < numbers.Length - 1; i++)
            {
                if (numbers[i] > numbers[i + 1])
                {
                    Console.WriteLine("no");
                    return;
                }
            }

            Console.WriteLine("yes");
            Console.WriteLine("{0} {1}", start + 1, end + 1);
        }

    }
}


using System;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var numbers = Console
                .ReadLine()
                .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(int.Parse)
                .ToArray();

            Solve(numbers);

            //Solve(new[] { 1, 2, 3, 7, 6, 5, 8, 9 });

            //Solve(new[] { 3, 2, 1 });
            //Solve(new[] { 2, 1, 3, 4 });
            //Solve(new[] { 3, 1, 2, 4 });
        }

        private static void swap(int[] arr, int start, int end)
        {
            while (start < end)
            {
                int tmp = arr[start];
                arr[start] = arr[end];
                arr[end] = tmp;
                start++;
                end--;
            }
        }

        private static void Solve(int[] numbers)
        {
            int start = 0;
            int end = numbers.Length - 1;

            while (start < numbers.Length - 1 && numbers[start] < numbers[start + 1])
                start++;
            while (start > 0 && numbers[start] < numbers[start - 1])
                start--;

            while (end > 0 && numbers[end] > numbers[end - 1])
                end--;
            while (end < numbers.Length - 1 && numbers[end] > numbers[end + 1])
                end++;

            swap(numbers, start, end);

            for (int i = 0; i < numbers.Length - 1; i++)
            {
                if (numbers[i] > numbers[i + 1])
                {
                    Console.WriteLine("no");
                    return;
                }
            }

            Console.WriteLine("yes");
            Console.WriteLine("{0} {1}", start + 1, end + 1);
        }

    }
}


using System;
     class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.In.ReadToEnd().Split(new char[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            int[] data = new int[input.Length];
            for (int d = 1; d < input.Length; ++d)
                data[d] = int.Parse(input[d]);
            input = null;
            data[0] = 1;

                int i = 2, j;
                for (; i < data.Length; i++)
                    if (data[i] < data[i - 1]) { i--; break; }
                for (j = i + 2; j < data.Length; ++j)
                    if (data[j] > data[j - 1]){ j--; break;}
                if (i<data.Length)
                {
                    if (j == data.Length) j--;
                    for(int temp, l = i, m = j;l<=m;)
                    {
                        temp = data[l];
                        data[l++] = data[m];
                        data[m--] = temp;
                    }
                    for(int r =2; r<data.Length; ++r)
                        if(data[r]<data[r-1]) { data[0] = 0; break; }

                }
                else i=j=1;
            Console.WriteLine(data[0] < 1 ? "no" : String.Format("yes\n{0} {1}", i, j));
        }
    }


using System;
using System.Linq;

namespace CSharp
{
    public class _451B
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();

            int index = 0;
            while ((index + 1 < n && a[index] < a[index + 1]) || index + 1 == n)
            {
                index++;
            }

            int left = Math.Min(n, index + 1);
            while ((index + 1 < n && a[index] > a[index + 1]) || index + 1 == n)
            {
                index++;
            }

            int right = Math.Min(n, index + 1);
            while ((index + 1 < n && a[index] < a[index + 1]) || index + 1 == n)
            {
                index++;
            }

            if (index == n && (left == 1 || a[left - 2] < a[right - 1]) && (right == n || a[right] > a[left - 1]))
            {
                Console.WriteLine("yes");
                Console.WriteLine($"{left} {right}");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }
            else
            {
                if (startIndex != -1 && endIndex != -1)
                    break;
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        int firstEle = arr[endIndex];
        int lastEle = arr[startIndex];

        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i < startIndex && i < endIndex)
            {
                continue;
            }
            else if (i == startIndex)
            {
                if (firstEle > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i >= endIndex)
            {
                if (i == endIndex)
                {
                    if (lastEle > arr[endIndex == arr.Length-1 ? endIndex - 1 : endIndex + 1])
                    {
                        check = false;
                        break;
                    }

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr =Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }
            else
            {
                if (startIndex != -1 && endIndex != -1)
                    break;
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        int firstEle = arr[endIndex];
        int lastEle = arr[startIndex];

        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i < startIndex && i < endIndex)
            {
                continue;
            }
            else if (i == startIndex)
            {
                if (firstEle < arr[startIndex-1])
                {
                    check = false;
                    break;
                }
            }
            else if (i >= endIndex)
            {
                if (i == endIndex)
                {
                    if (endIndex+1<arr.Length&&lastEle > arr[endIndex + 1])
                    {
                        check = false;
                        break;
                    }

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        for (int j = startIndex; j <= endIndex; j++)
        {
            ele.Add(arr[j]);
        }

        ele.Sort();
        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i - 1 <= startIndex && i - 1 <= endIndex)
            {
                continue;
            }
            else if (i < startIndex)
            {
                if (ele[0] > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i > endIndex)
            {
                if (i - endIndex < ele.Count && ele[ele.Count - 1] > arr[i])
                {
                    check = false;
                    break;

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        for (int j = startIndex; j <= endIndex; j++)
        {
            ele.Add(arr[j]);
        }

        ele.Sort();
        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i < startIndex && i< endIndex)
            {
                continue;
            }
            else if (i == startIndex)
            {
                if (ele[0] > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i > endIndex)
            {
                if (i-1 == endIndex)
                {
                    if (ele[ele.Count - 1] > arr[i])
                    {
                        check = false;
                        break;
                    }

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }
            else
            {
                if (startIndex != -1 && endIndex != -1)
                    break;
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        int firstEle = arr[endIndex];
        int lastEle = arr[startIndex];

        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i < startIndex && i< endIndex)
            {
                continue;
            }
            else if (i == startIndex)
            {
                if (firstEle > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i >= endIndex)
            {
                if (i-1 == endIndex)
                {
                    if (lastEle > arr[i])
                    {
                        check = false;
                        break;
                    }

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }
            else
            {
                if (startIndex != -1 && endIndex != -1)
                    break;
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (1));
            return;
        }
        List<int> ele = new List<int>();

        int firstEle = arr[endIndex];
        int lastEle = arr[startIndex];

        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i < startIndex && i< endIndex)
            {
                continue;
            }
            else if (i == startIndex)
            {
                if (firstEle > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i > endIndex)
            {
                if (i-1 == endIndex)
                {
                    if (lastEle > arr[i])
                    {
                        check = false;
                        break;
                    }

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class GFG
{

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int startIndex = -1;
        int endIndex = -1;

        for (int i = 1; i < n; i++)
        {
            if (arr[i] < arr[i - 1])
            {
                if (startIndex == -1)
                {
                    startIndex = i - 1;
                    endIndex = i;
                }
                else
                {
                    endIndex = i;

                }
            }

        }

        if (startIndex == 0 && endIndex == n - 1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
            return;
        }
        if (startIndex == -1 && endIndex == -1)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((1) + " " + (n));
            return;
        }
        List<int> ele = new List<int>();

        for (int j = startIndex; j <= endIndex; j++)
        {
            ele.Add(arr[j]);
        }

        ele.Sort();
        bool check = true;
        for (int i = 1; i < arr.Length; i++)
        {
            if (i - 1 <= startIndex && i - 1 <= endIndex)
            {
                continue;
            }
            else if (i < startIndex)
            {
                if (ele[0] > arr[i])
                {
                    check = false;
                    break;
                }
            }
            else if (i > endIndex)
            {
                if (i - endIndex < ele.Count && ele[ele.Count - 1] > arr[i])
                {
                    check = false;
                    break;

                }
                else
                {
                    if (arr[i - 1] > arr[i])
                    {
                        check = false;
                        break;

                    }
                }
            }
        }

        if (check)
        {
            Console.Write("yes");
            Console.WriteLine();
            Console.Write((startIndex + 1) + " " + (endIndex + 1));
        }
        else
        {
            Console.Write("no");
        }

    }

}


using System;
using System.Linq;

namespace EdxCourse
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            long last_elem = 0;
            long last_inc_elem = 0;
            long first_elem = 0;
            int first_ind = 1;
            int last_ind = 1;
            bool ended = false;
            bool started = false;

            for (int i = 0; i < n; i++)
            {
                long elem = long.Parse(input[i]);
                if (elem < last_elem)
                {
                    if (ended)
                    {
                        Console.WriteLine("no");
                        return;
                    }

                    if (!started)
                    {
                        first_elem = last_elem;
                        first_ind = i;
                    }

                    started = true;
                }
                else
                {
                    if (!ended && started)
                    {
                        if (elem < first_elem)
                        {
                            Console.WriteLine("no");
                            return;
                        }
                        if (last_elem < last_inc_elem)
                        {
                            Console.WriteLine("no");
                            return;
                        }

                        ended = true;
                        last_ind = i;
                    }

                    last_inc_elem = last_elem;
                }
                last_elem = elem;
            }

            if (last_elem < last_inc_elem)
            {
                Console.WriteLine("no");
                return;
            }

            if (!ended && started)
                last_ind = n;

            Console.WriteLine("yes");
            Console.WriteLine(first_ind + " " + last_ind);
        }
    }
}


using System;
using System.Linq;

namespace EdxCourse
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            long last_elem = 0;
            long first_elem = 0;
            int first_ind = 1;
            int last_ind = 1;
            bool ended = false;
            bool started = false;

            for (int i = 0; i < n; i++)
            {
                long elem = long.Parse(input[i]);
                if (elem < last_elem)
                {
                    if (ended)
                    {
                        Console.WriteLine("no");
                        return;
                    }

                    if (!started)
                    {
                        first_elem = last_elem;
                        first_ind = i;
                    }

                    started = true;
                }
                else
                {
                    if (!ended && started)
                    {
                        if (elem < first_elem)
                        {
                            Console.WriteLine("no");
                            return;
                        }

                        ended = true;
                        last_ind = i;
                    }
                }
                last_elem = elem;
            }

            if (!ended && started)
                last_ind = n;

            Console.WriteLine("yes");
            Console.WriteLine(first_ind + " " + last_ind);
        }
    }
}


using System;

namespace Sort_the_Array
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int left = 0,
                right = 0;
            bool ans = false;
            for (int i = 0; i < n; i++)
            {
                if(arr[i] == i + 1)
                {
                    continue;
                }
                else
                {
                    if (ans == false)
                    {
                        int indextemp = i,
                        indextemp2 = arr[i] - 1;
                        right = arr[i];
                        left = arr[indextemp2];
                        if (arr[indextemp2] == i + 1)
                        {
                            ans = true;
                            arr[indextemp2] = arr[i];
                            arr[i] = i + 1;

                        }
                        else
                        {
                            break;
                        }
                    }

                }
            }

            if(ans == false && left ==0 && right == 0)
            {
                Console.WriteLine("yes");
                Console.WriteLine("1 1");
            }
            else if(ans == true)
            {
                Console.WriteLine("yes");
                Console.WriteLine($"{left} {right}");
            }
            else if(ans == false)
            {
                Console.WriteLine("no");
            }

        }
    }
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int adj=(int)(g[node].size());
        for(int i=0;i<adj;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int q;
    int siz=0;
    int in1,in2,in3;

    cin>>q;
    for(;q>0;q--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if((((a[i]<in2)&&(in2<b[i]))||((a[i]<in3)&&(in3<b[i])))||(((in2<a[i])&&(a[i]<in3))||((in2<b[i])&&(b[i]<in3))))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            in2--;
            in3--;
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int children=g[node].size();
        for(int i=0;i<children;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int lines;
    int siz=0;
    int in1,in2,in3;

    cin>>lines;
    for(;lines>0;lines--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((in2<a[i])&&(a[i]<in3)))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int children=g[node].size();
        for(int i=0;i<children;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(visited[g[node][i]]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g;
    vector<int> a;
    vector<int> b;
    int lines;
    int siz=0;
    int i1,i2,i3;

    cin>>lines;
    for(;lines>0;lines--)
    {
        cin>>i1>>i2>>i3;
        if(i1==1)
        {
            a.push_back(i2);
            b.push_back(i3);
            g.resize(siz+1);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<i2)&&(i2<b[i]))||((i2<a[i])&&(a[i]<i3)))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            if(f1(g,siz,i2,i3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int children=g[node].size();
        for(int i=0;i<children;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g;
    vector<int> a;
    vector<int> b;
    int lines;
    int siz=0;
    int in1,in2,in3;

    cin>>lines;
    for(;lines>0;lines--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            //g.resize(siz+1);
            vector<int> temp;
            g.push_back(temp);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((in2<a[i])&&(a[i]<in3)))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int children=g[node].size();
        for(int i=0;i<children;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g;
    vector<int> a;
    vector<int> b;
    int lines;
    int siz=0;
    int in1,in2,in3;

    cin>>lines;
    for(;lines>0;lines--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            g.resize(siz+1);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((in2<a[i])&&(a[i]<in3)))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int adj=(int)(g[node].size());
        for(int i=0;i<adj;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int q;
    int siz=0;
    int in1,in2,in3;

    cin>>q;
    for(;q>0;q--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((a[i]<in3)&&(in3<b[i])))
                    g[siz].push_back(i);

                if(((in2<a[i])&&(a[i]<in3))||((in2<b[i])&&(b[i]<in3)))
                    g[i].push_back(siz);
            }
            siz++;
        }
        else
        {
            in2--;
            in3--;
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int adj=(int)(g[node].size());
        for(int i=0;i<adj;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int q;
    int siz=0;
    int in1,in2,in3;

    cin>>q;
    for(;q>0;q--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((a[i]<in3)&&(in3<b[i])))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            in2--;
            in3--;
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int adj=(int)(g[node].size());
        for(int i=0;i<adj;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int q;
    int siz=0;
    int in1,in2,in3;

    cin>>q;
    for(;q>0;q--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if(((in2<a[i])&&(a[i]<in3))||((in2<b[i])&&(b[i]<in3)))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            in2--;
            in3--;
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include<cstdlib>
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<string>
#include<string.h>

#include<vector>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>

#include<ctype.h>
#include<math.h>
using namespace std;

bool f1(const vector< vector<int> > &g, const int &siz, const int &start, const int &target)
{
    stack<int> dfs;
    vector<bool> visited(siz,false);
    dfs.push(start);
    int node;
    while(!(dfs.empty()))
    {
        node=dfs.top();
        dfs.pop();
        int adj=(int)(g[node].size());
        for(int i=0;i<adj;i++)
        {
            if(g[node][i]==target)
                return true;
            if(visited[g[node][i]])
                continue;
            visited[g[node][i]]=true;
            dfs.push(g[node][i]);
        }
    }

    return false;
}

int main()
{
    vector< vector<int> > g(100);
    vector<int> a;
    vector<int> b;
    int q;
    int siz=0;
    int in1,in2,in3;

    cin>>q;
    for(;q>0;q--)
    {
        cin>>in1>>in2>>in3;
        if(in1==1)
        {
            a.push_back(in2);
            b.push_back(in3);
            for(int i=0;i<siz;i++)
            {
                if(((a[i]<in2)&&(in2<b[i]))||((a[i]<in3)&&(in3<b[i])))
                {
                    g[i].push_back(siz);
                    g[siz].push_back(i);
                }
            }
            siz++;
        }
        else
        {
            if(f1(g,siz,in2,in3))
                cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 1010;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int a,b,c,d;

	scanf(" %d %d",&a,&b);

	ar[++cnt].fi=a;
	ar[cnt].se=b;

	for ( int i=1 ; i<cnt ; i++ ){
		c=ar[i].fi;	d=ar[i].se;
		if ( ( c<a && a<d ) || ( c<b && b<d ) )
			ways[cnt][i]=1;
	}

	int flag=1;

	while ( flag ){

		flag=0;

		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j] )
					for ( int k=j+1 ; k<=cnt ; k++ )
						if ( i!=k && j!=k && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=1;
						}

	}

}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 110;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int x,y;

	scanf(" %d %d",&x,&y);

	ar[++cnt].fi=x;
	ar[cnt].se=y;

	for ( int i=1 ; i<cnt ; i++ ){

		int a=ar[i].fi,b=ar[i].se;

		if ( a<x && x<b || a<y && y<b ){
			ways[i][cnt]=ways[cnt][i]=1;

		}

	}

	int flag=1;

	while ( flag ){
		flag=0;
		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j]  )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( k!=i && k!=j && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=ways[k][j]=1;
						}

	}
}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 1010;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int a,b,c,d;

	scanf(" %d %d",&a,&b);

	ar[++cnt].fi=a;
	ar[cnt].se=b;

	ways[cnt][cnt]=1;

	for ( int i=1 ; i<cnt ; i++ ){
		c=ar[i].fi;	d=ar[i].se;
		if ( ( c<a && a<d ) || ( c<b && b<d ) )
			ways[i][cnt]=1;
	}

	int flag=1;

	while ( flag ){

		flag=0;

		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[j][i] )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( i!=k && j!=k && ways[k][i] && !ways[j][k] ){
							flag=1;
							ways[j][k]=1;
						}

	}

}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 1010;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int a,b,c,d;

	scanf(" %d %d",&a,&b);

	ar[++cnt].fi=a;
	ar[cnt].se=b;

	for ( int i=1 ; i<=cnt ; i++ )
		for ( int j=1 ; j<=cnt ; j++ ){
			a=ar[i].fi;	b=ar[i].se;
			c=ar[j].fi;	d=ar[j].se;

			if ( (c<a && a<d) || (c<b && b<d) ){
				ways[i][j]=1;
				//~ printf("------------------>>>%d %d\n",i,j);
			}
		}

	int flag=1;

	while ( flag ){

		flag=0;

		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[j][i] )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( i!=k && j!=k && ways[i][k] && !ways[j][k] ){
							flag=1;
							//~ printf("-------------->>>>%d %d\n",j,k);
							ways[j][k]=1;
						}

	}

}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 1010;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int a,b,c,d;

	scanf(" %d %d",&a,&b);

	ar[++cnt].fi=a;
	ar[cnt].se=b;

	for ( int i=1 ; i<=cnt ; i++ )
		for ( int j=1 ; j<=cnt ; j++ ){
			a=ar[i].fi;	b=ar[i].se;
			c=ar[j].fi;	d=ar[j].se;

			if ( (c<a && a<d) || (c<b && b<d) )
				ways[i][j]=1;
		}

	int flag=1;

	while ( flag ){

		flag=0;

		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j] )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( i!=k && j!=k && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=1;
						}

	}

}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 1010;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int a,b,c,d;

	scanf(" %d %d",&a,&b);

	ar[++cnt].fi=a;
	ar[cnt].se=b;

	for ( int i=1 ; i<cnt ; i++ ){
		c=ar[i].fi;	d=ar[i].se;
		if ( ( c<a && a<d ) || ( c<b && b<d ) )
			ways[cnt][i]=1;
	}

	int flag=1;

	while ( flag ){

		flag=0;

		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j] )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( i!=k && j!=k && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=1;
						}

	}

}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 110;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int x,y;

	scanf(" %d %d",&x,&y);

	ar[++cnt].fi=x;
	ar[cnt].se=y;

	ways[cnt][cnt]=1;

	for ( int i=1 ; i<cnt ; i++ ){

		int a=ar[i].fi,b=ar[i].se;

		if ( a<x && x<b || a<y && y<b ){
			ways[i][cnt]=ways[cnt][i]=1;

		}

	}

	int flag=1;

	while ( flag ){
		flag=0;
		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j]  )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( k!=i && k!=j && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=ways[k][j]=1;
						}

	}
}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#define fi first
#define se second

using namespace std;

const int MAXN = 110;

int N,cnt;

typedef pair<int,int> ii;

ii ar[MAXN];

int ways[MAXN][MAXN];

void f(){

	int x,y;

	scanf(" %d %d",&x,&y);

	ar[++cnt].fi=x;
	ar[cnt].se=y;

	for ( int i=1 ; i<cnt ; i++ ){

		int a=ar[i].fi,b=ar[i].se;

		if ( a<x && x<b || a<y && y<b ){
			ways[i][cnt]=ways[cnt][i]=1;
			printf("%d %d bagladik\n",i,cnt);
		}

	}

	int flag=1;

	while ( flag ){
		flag=0;
		for ( int i=1 ; i<=cnt ; i++ )
			for ( int j=1 ; j<=cnt ; j++ )
				if ( i!=j && ways[i][j]  )
					for ( int k=1 ; k<=cnt ; k++ )
						if ( k!=i && k!=j && ways[i][k] && !ways[j][k] ){
							flag=1;
							ways[j][k]=ways[k][j]=1;
						}

	}
}

int main(){

	cin >> N;

	int a,h,g;

	for ( int i=1 ; i<=N ; i++ ){

		scanf(" %d",&a);

		if ( a==1 ) f();
		else{

			scanf(" %d %d",&h,&g);
			if ( ways[h][g] )	puts("YES");
			else puts("NO");

		}

	}

	return 0;

}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
//weighted union find algorithm..
#include <iostream>
#include <vector>
using namespace std;
class Weighted_Union_Find
{
private:
    vector<int> id;
    vector<int> size;
    int components;

public:
    Weighted_Union_Find(int N)
    {
        components=N;
        for(int i=0;i<N;++i)id.push_back(i);
        for(int i=0;i<N;++i)size.push_back(1);
    }

    int Componnts()
    {return components;}

    bool connected(int p,int q)
    {return Find(p)==Find(q);}

    int Find(int p)
    {
        while(id[p]!=p)p=id[p];
        return p;
    }

    void Union(int p,int q)
    {
        int idp=Find(p);
        int idq=Find(q);
        if(idp==idq) return;

        else
        {
            components--;
            if(size[idp]>size[idq])
            {
                id[idq]=idp;
                size[p]+=size[q];
            }
            else
            {
                id[idp]=idq;
                size[q]+=size[p];
            }
        }
    }

};

struct Node
{
    int strt;
    int end;
};

vector<Node> arr;
int main()
{
    int N,x,a,b,point=0;
    Node temp;
    cin>>N;
    Weighted_Union_Find w(101);

    for(int i=0;i<N;++i)
    {
        cin>>x;
        if(x==1)
        {
            cin>>temp.strt;
            cin>>temp.end;
            for(unsigned int j=0;j<arr.size();++j)
            {
               if((arr[j].strt>temp.strt && arr[j].strt<temp.end) || (arr[j].end>temp.strt && arr[j].end<temp.end))
               {
                    w.Union(point,j);
               }
               else if((temp.strt>arr[j].strt && temp.strt<arr[j].end) || (temp.end>arr[j].strt && temp.end<arr[j].end))
                {
                    w.Union(point,j);
                }
            }
            ++point;
            arr.push_back(temp);
        }
        else
        {
            cin>>a>>b;
            if(w.connected(a-1,b-1))
            cout<<"YES\n";
            else
            cout<<"NO\n";
        }
    }

}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
class Weighted_Union_Find
{
private:
    vector<int> id;
    vector<int> size;
    int components;

public:
    Weighted_Union_Find(int N)
    {
        components=N;
        for(int i=0;i<N;++i)id.push_back(i);
        for(int i=0;i<N;++i)size.push_back(1);
    }

    int Componnts()
    {return components;}

    bool connected(int p,int q)
    {return Find(p)==Find(q);}

    int Find(int p)
    {
        while(id[p]!=p)p=id[p];
        return p;
    }

    void Union(int p,int q)
    {
        int idp=Find(p);
        int idq=Find(q);
        if(idp==idq) return;

        else
        {
            components--;
            if(size[idp]>size[idq])
            {
                id[idq]=idp;
                size[p]+=size[q];
            }
            else
            {
                id[idp]=idq;
                size[q]+=size[p];
            }
        }
    }

};

struct Node
{
    int strt;
    int end;
};

vector<Node> arr;
int main()
{
    int N,x,a,b,point=0;
    Node temp;
    cin>>N;

    Weighted_Union_Find w(101);

    for(int i=0;i<N;++i)
    {
        cin>>x;
        if(x==1)
        {
            cin>>temp.strt;
            cin>>temp.end;
            for(int j=0;j<arr.size();++j)
            {
                if((temp.strt>arr[j].strt && temp.strt<arr[j].end) ^ (temp.end>arr[j].strt && temp.end<arr[j].end))
                {
                    w.Union(point,j);
                }
            }
            ++point;
            arr.push_back(temp);
        }
        else
        {
            cin>>a>>b;
            if(w.connected(a-1,b-1))
            cout<<"YES\n";
            else
            cout<<"NO\n";
        }
    }
}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
//weighted union find algorithm..
#include <iostream>
#include <vector>
using namespace std;
class Weighted_Union_Find
{
private:
    vector<int> id;
    vector<int> size;
    int components;

public:
    Weighted_Union_Find(int N)
    {
        components=N;
        for(int i=0;i<N;++i)id.push_back(i);
        for(int i=0;i<N;++i)size.push_back(1);
    }

    int Componnts()
    {return components;}

    bool connected(int p,int q)
    {return Find(p)==Find(q);}

    int Find(int p)
    {
        while(id[p]!=p)p=id[p];
        return p;
    }

    void Union(int p,int q)
    {
        int idp=Find(p);
        int idq=Find(q);
        if(idp==idq) return;

        else
        {
            components--;
            if(size[idp]>size[idq])
            {
                id[idq]=idp;
                size[p]+=size[q];
            }
            else
            {
                id[idp]=idq;
                size[q]+=size[p];
            }
        }
    }

};

struct Node
{
    int strt;
    int end;
};

vector<Node> arr;
int main()
{
    int N,x,a,b,point=0;
    Node temp;
    cin>>N;
    Weighted_Union_Find w(101);

    for(int i=0;i<N;++i)
    {
        cin>>x;
        if(x==1)
        {
            cin>>temp.strt;
            cin>>temp.end;
            for(unsigned int j=0;j<arr.size();++j)
            {
               if((arr[j].strt>temp.strt && arr[j].strt<temp.end) ^ (arr[j].end>temp.strt && arr[j].end<temp.end))
               {
                    w.Union(point,j);
               }
               else if((temp.strt>arr[j].strt && temp.strt<arr[j].end) ^ (temp.end>arr[j].strt && temp.end<arr[j].end))
                {
                    w.Union(point,j);
                }
            }
            ++point;
            arr.push_back(temp);
        }
        else
        {
            cin>>a>>b;
            if(w.connected(a-1,b-1))
            cout<<"YES\n";
            else
            cout<<"NO\n";
        }
    }

}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
class Weighted_Union_Find
{
private:
	vector<int> id;
	vector<int> size;
	int components;

public:
	Weighted_Union_Find(int N)
	{
		for(int i=0;i<N;++i)id.push_back(i);
	}

	int Componnts()
	{return components;}

	bool connected(int p,int q)
	{return Find(p)==Find(q);}

	int Find(int p)
	{
		while(id[p]!=p)p=id[p];
		return p;
	}

	void Union(int p,int q)
	{
		int idp=Find(p);
		int idq=Find(q);
		if(idp==idq) return;
		id[idq]=idp;
	}

};

struct Node
{
	int strt;
	int end;
};

vector<Node> arr;
int main()
{
	int N,x,a,b,point=0;
	Node temp;
	cin>>N;

	Weighted_Union_Find w(101);

	for(int i=0;i<N;++i)
	{
		cin>>x;
		if(x==1)
		{
			cin>>temp.strt;
			cin>>temp.end;
			for(int j=0;j<arr.size();++j)
			{
				if((temp.strt>arr[j].strt && temp.strt<arr[j].end) ^ (temp.end>arr[j].strt && temp.end<arr[j].end))
				{
					w.Union(point,j);
				}
			}
			++point;
			arr.push_back(temp);
		}
		else
		{
			cin>>a>>b;
			if(w.connected(a-1,b-1))
			cout<<"YES\n";
			else
			cout<<"NO\n";
		}
	}

}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
class Weighted_Union_Find
{
private:
    vector<int> id;
    vector<int> size;
    int components;

public:
    Weighted_Union_Find(int N)
    {
        components=N;
        for(int i=0;i<N;++i)id.push_back(i);
        for(int i=0;i<N;++i)size.push_back(1);
    }

    int Componnts()
    {return components;}

    bool connected(int p,int q)
    {return Find(p)==Find(q);}

    int Find(int p)
    {
        while(id[p]!=p)p=id[p];
        return p;
    }

    void Union(int p,int q)
    {
        int idp=Find(p);
        int idq=Find(q);
        if(idp==idq) return;

        else
        {
            components--;
            if(size[idp]>size[idq])
            {
                id[idq]=idp;
                size[p]+=size[q];
            }
            else
            {
                id[idp]=idq;
                size[q]+=size[p];
            }
        }
    }

};

struct Node
{
    int strt;
    int end;
};

vector<Node> arr;
int main()
{
    int N,x,a,b,point=0;
    Node temp;
    cin>>N;

    Weighted_Union_Find w(N+1);

    for(int i=0;i<N;++i)
    {
        cin>>x;
        if(x==1)
        {
            cin>>temp.strt;
            cin>>temp.end;
            ++point;
            for(int j=0;j<arr.size();++j)
            {
                if((temp.strt>arr[j].strt && temp.strt<arr[j].end) || (temp.end>arr[j].strt && temp.end<arr[j].end))
                {
                    w.Union(point,j+1);
                    //cout<<i+1<<" "<<j+1<<endl;
                }
            }
            arr.push_back(temp);
        }
        else
        {
            cin>>a>>b;
            if(w.connected(a,b))
            cout<<"YES\n";
            else
            cout<<"NO\n";
        }
    }
}


//weighted union find algorithm..
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cassert>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<climits>
#include<iterator>
#include<string>
#include<list>
#include<functional>
#include<bitset>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<numeric>
#define MOD 1000000007

using namespace std;
class Weighted_Union_Find
{
private:
    vector<int> id;
    vector<int> size;
    int components;

public:
    Weighted_Union_Find(int N)
    {
        components=N;
        for(int i=0;i<N;++i)id.push_back(i);
        for(int i=0;i<N;++i)size.push_back(1);
    }

    int Componnts()
    {return components;}

    bool connected(int p,int q)
    {return Find(p)==Find(q);}

    int Find(int p)
    {
        while(id[p]!=p)p=id[p];
        return p;
    }

    void Union(int p,int q)
    {
        int idp=Find(p);
        int idq=Find(q);
        if(idp==idq) return;

        else
        {
            components--;
            if(size[idp]>size[idq])
            {
                id[idq]=idp;
                size[p]+=size[q];
            }
            else
            {
                id[idp]=idq;
                size[q]+=size[p];
            }
        }
    }

};

struct Node
{
    int strt;
    int end;
};

vector<Node> arr;
int main()
{
    int N,x,a,b;
    Node temp;
    cin>>N;
    Weighted_Union_Find w(N+1);

    for(int i=0;i<N;++i)
    {
        cin>>x;
        if(x==1)
        {
            cin>>temp.strt;
            cin>>temp.end;
            for(int j=0;j<arr.size();++j)
            {
                if((temp.strt>arr[j].strt && temp.strt<arr[j].end) || (temp.end>arr[j].strt && temp.end<arr[j].end))
                w.Union(i+1,j+1);
            }
            arr.push_back(temp);
        }
        else
        {
            cin>>a>>b;
            if(w.connected(a,b))
            cout<<"YES\n";
            else
            cout<<"NO\n";
        }
    }
}