#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	long long int n,x,y;
	while(cin>>n)
	{
		cin>>x>>y;
		long long int wea[n]={0},ans=0,t;
		for(long long int i=0;i<n;i++)
			cin>>wea[i];

		for(long long int i=0;i<n;i++)
		{
			ans=0;
			for(long long int j=i-x;j<i;j++)
			{
				if(j<0)
					continue;
				//cout<<j<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>=wea[j])
				{
					ans=-1;
					break;
				}
			}
			if(ans==-1)
				continue;
			for(long long int j=i+1;j<=i+y;j++)
			{
				if(i==j||j>=n)
					continue;
				//cout<<j<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>=wea[j])
				{
					ans=-1;
					break;
				}
			}
			if(ans==0)
			{
				ans=i;
				//cout<<"XD"<<ans<<endl;
				break;
			}
		}
		if(ans==-1)
			ans=0;
		cout<<ans+1<<endl;

	}
	return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,x,y;
	while(cin>>n)
	{
		cin>>x>>y;
		long long int wea[n]={0},ans=-1,t;
		for(int i=0;i<n;i++)
			cin>>wea[i];
		for(int i=x;i<n;i++)
		{
			if(i+y>=n)
				t=n-1;
			else
				t=i+y;
			for(int j=i-x;j<=t;j++)
			{
				//cout<<ans<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>wea[j])
				{
					ans=-1;
					break;
				}
				if(j==t)
					ans=0;
				//cout<<j<<" "<<t<<endl;
			}
			if(ans==0)
			{
				ans=i;
				break;
			}
		}
		if(ans!=-1)
			cout<<ans+1<<endl;
		else
		{
			//cout<<"XD"<<endl;
			ans=1000000000;
			int num;
			for(int i=0;i<n;i++)
			{
				if(ans>wea[i])
				{
					ans=wea[i];
					num=i;
				}
			}
			cout<<num+1<<endl;
		}

	}
	return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	long long int n,x,y;
	while(cin>>n)
	{
		cin>>x>>y;
		long long int wea[n]={0},ans=0,t;
		for(long long int i=0;i<n;i++)
			cin>>wea[i];

		for(long long int i=0;i<n;i++)
		{
			ans=0;
			for(long long int j=i-x;j<i;j++)
			{
				if(j<0)
					continue;
				//cout<<j<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>=wea[j])
				{
					ans=-1;
					break;
				}
			}
			if(ans==-1)
				continue;
			for(long long int j=i+1;j<=i+y;j++)
			{
				if(i==j||j>n)
					continue;
				//cout<<j<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>=wea[j])
				{
					ans=-1;
					break;
				}
			}
			if(ans==0)
			{
				ans=i;
				//cout<<"XD"<<ans<<endl;
				break;
			}
		}
		if(ans==-1)
			ans=0;
		cout<<ans+1<<endl;

	}
	return 0;
}


#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n,x,y;
	while(cin>>n)
	{
		cin>>x>>y;
		long long int wea[n]={0},ans=-1,t;
		for(int i=0;i<n;i++)
			cin>>wea[i];
		for(int i=x;i<n;i++)
		{
			if(i+y>=n)
				t=n-1;
			else
				t=i+y;
			for(int j=i-x;j<=t;j++)
			{
				//cout<<t<<" "<<wea[i]<<" "<<wea[j]<<endl;
				if(wea[i]>wea[j])
				{
					ans=0;
					break;
				}
				ans=-1;
			}
			if(ans!=0)
			{
				ans=i;
				break;
			}
		}
		if(ans!=-1)
			cout<<ans+1<<endl;
		else
		{
			ans=1000000000;
			int num;
			for(int i=0;i<n;i++)
			{
				if(ans>wea[i])
				{
					ans=wea[i];
					num=i;
				}
			}
			cout<<num+1\<<endl;
		}

	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	for(int i = max(0,j-x); i< j;i++)
	{
		if(a[i] <= a[i+1])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[i-1])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =0 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	if(j-x <0)	return 0;
	for(int i = j-x; i>=0 && i< j;i++)
	{
		if(a[i] <= a[i+1])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[i-1])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =1 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	for(int i = max(0,j-x); i< j-1;i++)
	{
		if(a[i] <= a[i+1])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[i-1])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =0 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	for(int i = max(0,j-x); i>=0 && i< j;i++)
	{
		if(a[i] <= a[i+1])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[i-1])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =0 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	for(int i = max(0,j-x); i< j;i++)
	{
		if(a[i] <= a[j])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[j])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =0 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

bool check(int a[], int n, int x, int y, int j)
{
	if(j-x <0)	return 0;
	for(int i = j-x; i>=0 && i< j;i++)
	{
		if(a[i] <= a[i+1])
			return 0;
	}
	for(int i= j+1 ; i <= j+y && i < n; i++)
	{
		if(a[i] <= a[i-1])
			return 0;
	}

	return 1;
}

void doit()
{
	int n ; cin >> n;
	int x, y ; cin >> x >> y;

	int a[n] ;
	for(int i= 0;i < n;i++)
		cin >> a[i];

	int ans=n;

	for(int i =0 ;i < n; i++)
	{
		if(check(a, n, x, y, i))
		{
			ans=i+1;
			break;
		}
	}

	cout<<ans;

}

int main()
{
	ios:: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	doit();

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n],count=0,mount=0,d=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i+1;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    if(x==0 || y==0)
        cout<<d;
    else
        cout<<d+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll i,a[n],count=0,mount=0,d=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i+1;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    cout<<d+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n+1],count=0,mount=0,d=0,t=1;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i+1;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    cout<<max(t,d);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
       ll d=1,flag=0;
       while(d<=x&&i-d>=0)
       {
           if(a[i-d]<a[i])
              flag=1;
           d++;
       }
       d=1;
       while(d<=y&&i+d<n)
       {
           if(a[i]>a[i+d])
              flag=1;
           d++;
       }
       if(flag==0)
       {
          cout<<i+1;
          break;
       }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n+1],count=0,mount=0,d=0,t=1;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    if(y!=0)
        cout<<d+1;
    else
        cout<<max(t,d);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll i,a[n],count=0,mount=0,d=0;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i+1;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    if(x==0 || y==0 || x==0&&y==0)
        cout<<d;
    else
        cout<<d+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y;
    cin>>n>>x>>y;
    ll i,a[n],count=0,mount=0,d;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
           d=i+1;
           count++;
        }
        else
            mount++;
        if(count==x && mount==y || count==x&&i==n-1)
            break;
    }
    cout<<d+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
    {
       ll d=1,flag=0;
       while(d<=x&&i-d>=0)
       {
           if(a[i-d]<a[i])
              flag=1;
           d++;
       }
       d=1;
       while(d<=y&&i+d<=n)
       {
           if(a[i]>a[i+d])
            flag=1;
           d++;
       }
       if(flag==0)
       {
          cout<<i+1;
          break;
       }
    }
    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    cin>>x[0];
    int i;
    for(i=1;i<n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i+1<n;i++)
    {
        if(x[i-1]>x[i]&&x[i]<x[i+1])
        {
            int op=INF;
            for(int j=i-a;j<=i+b&&j<n;j++)
            {
                if(j<0) j=0;
                op=min(x[j],op);
            }
            if(op==x[i]) {printf("%d\n",i+1);break;}
        }
    }
    if(i==n-1)
    {
        if(x[0]<x[1]) printf("1\n");
    else printf("%d\n",n);
    }

    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    cin>>x[0];
    int i=0;
    for(i=1;i<n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i+1<n;i++)
    {
        if(x[i-1]>=x[i]&&x[i]<=x[i+1])
        {
            int op=INF;
            for(int j=i-a;j<=i+b&&j<n;j++)
            {
                if(j<0) j=0;
                op=min(x[j],op);
            }
            if(op==x[i]) {printf("%d\n",i+1);break;}
        }
    }
    if(i==n-1)
    {
        if(i==0) printf("1\n");
        else if(x[n-2]>=x[n-1]) printf("%d\n",n);
    }

    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    cin>>x[0];
    int i=0;
    for(i=1;i<n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i+1<n;i++)
    {
        if(x[i-1]>=x[i]&&x[i]<=x[i+1])
        {
            int op=INF;
            for(int j=i-a;j<=i+b&&j<n;j++)
            {
                if(j<0) j=0;
                op=min(x[j],op);
            }
            if(op==x[i]) {printf("%d\n",i+1);break;}
        }
    }
    if(i==n-1)
    {

        if(x[n-2]>=x[n-1]) printf("%d\n",n);
    }
    if(n==1) printf("1\n");
    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    cin>>x[0];
    int i=0;
    for(i=1;i<n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i+1<n;i++)
    {
        if(x[i-1]>=x[i]&&x[i]<=x[i+1])
        {
            int op=INF;
            for(int j=i-a;j<=i+b&&j<n;j++)
            {
                if(j<0) j=0;
                op=min(x[j],op);
            }
            if(op==x[i]) {printf("%d\n",i+1);break;}
        }
    }
    if(i==n-1)
    {

        if(x[n-2]>=x[n-1]) printf("%d\n",n);
    }
    if(i==0) printf("1\n");
    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>x[i];
    }
    int j;
    for(i=1;i<=n;i++)
    {
        for(j=max(1,i-a);j<=min(n,i+b);j++)
        {
            if(i!=j&&x[j]<=x[i]) break;
        }
        if(j>min(n,i+b)) break;
    }
    cout<<i<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define INF 0x3f3f3f;
using namespace std;

int x[1000000];
int main() {
    int n,a,b,cnt=0,cns=0;
    cin>>n>>a>>b;
    cin>>x[0];
    int i;
    for(i=1;i<n;i++)
    {
        cin>>x[i];
    }
    for(i=1;i+1<n;i++)
    {
        if(x[i-1]>=x[i]&&x[i]<=x[i+1])
        {
            int op=INF;
            for(int j=i-a;j<=i+b&&j<n;j++)
            {
                if(j<0) j=0;
                op=min(x[j],op);
            }
            if(op==x[i]) {printf("%d\n",i+1);break;}
        }
    }
    if(i==n-1)
    {
        if(x[n-2]>=x[n-1]) printf("%d\n",n);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n,x,y;
cin>>n>>x>>y;
ll a[n+5];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int k=0;
for(int i=0;i<n;i++)
{
 int f=1;
 for(int j=i-x;j<=i+y;j++)
 {
     if(a[i]>a[j])
     {
         break;
         f=0;
     }
 }
 if(f==1)
 {
     cout<<i+1<<endl;
     return 0;
 }
}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   ll n,x,y,i;
    cin>>n>>x>>y;
    ll a[n+100];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    bool f=1;
    for(i=0; i<n; i++)
    {
        f=true;
        for(long j=i-x; j<=i+y; j++)
        {
            if(j>=0 && j<n)
            {
                if(a[i]>a[j])
                {
                    f=0;
                    break;
                }
            }
        }
        if(f==1)
        {
            cout<<i+1;
         return 0;
        }

    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
int n,x,y;
cin>>n>>x>>y;
int a[n+5];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int k=0;
for(int i=0;i<n;i++)
{
 int f=1;
 for(int j=i-x;j<=i+y;j++)
 {
     if(a[i]>a[j])
     {
         break;
         f=0;
     }
 }
 if(f==1)
 {
     cout<<i+1<<endl;
     return 0;
 }
}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll n,x,y;
cin>>n>>x>>y;
ll a[n+5];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int k=0;
for(int i=0;i<n;i++)
{
 if(a[i]<a[k])
 {
     k=i;
 }
 if(i-k==y)
 {
     break;
 }
}
cout<<k+1<<endl;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, a[N];

bool check()
{
	bool check = true;
	for(int i=1;i<n;++i)
		if(a[i] < a[i-1])
			check = false;
	return check;
}

int main()
{
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i];
	if(check())
	{
		printf("YES\n");
		return 0;
	}
	int prev[n], last[n];
	prev[0] = 0; last[n-1] = n-1;
	// storing prev and last
	for(int i=1;i<n;++i)
	{
		if(a[i] != a[i-1])
			prev[i] = i;
		else prev[i] = prev[i-1];
	}
	for(int i=n-2;i>=0;--i)
	{
		if(a[i] != a[i+1])
			last[i] = i;
		else last[i] = last[i+1];
	}
	int start=-1, end =-1;
	for(int i=0;i<n;++i)
	{
		if(i< n && a[i] > a[i+1])
		{
			if(start != -1)
			{
				swap(a[prev[start]], a[i+1]);
				if(check())
				{
					printf("YES\n");
					return 0;
				}
				break;
			}
			swap(a[i + 1], a[prev[i]]);
			if(check())
			{
				printf("YES\n");
				return 0;
			}
			if(prev[i] != i)break;
			swap(a[i+1], a[i]);
			start = i;
		}

	}
	printf("NO\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, a[N];

bool check()
{
	bool check = true;
	for(int i=1;i<n;++i)
		if(a[i] < a[i-1])
			check = false;
	return check;
}

int main()
{
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i];
	if(check())
	{
		printf("YES\n");
		return 0;
	}
	int prev[n], last[n];
	prev[0] = 0; last[n-1] = n-1;
	// storing prev and last
	for(int i=1;i<n;++i)
	{
		if(a[i] != a[i-1])
			prev[i] = i;
		else prev[i] = prev[i-1];
	}
	for(int i=n-2;i>=0;--i)
	{
		if(a[i] != a[i+1])
			last[i] = i;
		else last[i] = last[i+1];
	}
	int start=-1, end =-1;
	for(int i=0;i<n-1;++i)
	{
		if(a[i] > a[i+1])
		{
			if(start != -1)
			{
				swap(a[prev[start]], a[i+1]);
				if(check())
				{
					printf("YES\n");
					return 0;
				}
				break;
			}
			swap(a[i + 1], a[prev[i]]);
			if(check())
			{
				printf("YES\n");
				return 0;
			}
			if(prev[i] != i)break;
			swap(a[i+1], a[i]);
			swap(a[i], a[last[i+1]]);
			if(check())
			{
				printf("YES\n"); return 0;
			}
			if(last[i+1] != i+1)
				break;
			swap(a[i], a[last[i+1]]);
			start = i;
		}

	}
	printf("NO\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, a[N];

bool check()
{
	bool check = true;
	for(int i=1;i<n;++i)
		if(a[i] < a[i-1])
			check = false;
	return check;
}

int main()
{
	cin>>n;
	for(int i=0;i<n;++i)
		cin>>a[i];
	if(check())
	{
		printf("YES\n");
		return 0;
	}
	int prev[n], last[n];
	prev[0] = 0; last[n-1] = n-1;
	// storing prev and last
	for(int i=1;i<n;++i)
	{
		if(a[i] != a[i-1])
			prev[i] = i;
		else prev[i] = prev[i-1];
	}
	for(int i=n-2;i>=0;--i)
	{
		if(a[i] != a[i+1])
			last[i] = i;
		else last[i] = last[i+1];
	}
	int start=-1, end =-1;
	for(int i=0;i<n-1;++i)
	{
		if(a[i] > a[i+1])
		{
			if(start != -1)
			{
				swap(a[prev[start]], a[i+1]);
				if(check())
				{
					printf("YES\n");
					return 0;
				}
				break;
			}
			swap(a[i + 1], a[prev[i]]);
			if(check())
			{
				printf("YES\n");
				return 0;
			}
			if(prev[i] != i)break;
			swap(a[i+1], a[i]);
			start = i;
		}

	}
	printf("NO\n");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];
vector<int> b;

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(b[i] > b[i + 1]) return false;
    }
    return true;
}

bool check2(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check2()){
        cout << "YES" << endl;
        exit(0);
    }
    for(int i = 0; i < n; i++){
        b.push_back(a[i]);
        if(b.size() >= 3){
            int t = b.size();
            if(b[t - 1] == b[t - 2] && b[t - 2] == b[t - 3]) b.pop_back();
        }
    }
    n = b.size();
    vector<int> it;
    for(int i = 0; i < n - 1; i++){
        if(b[i] > b[i + 1]){
            int lo = i;
            int hi = i + 1;
            if(lo - 1 >= 0 && b[lo - 1] == b[lo]) lo--;
            if(hi + 1 < n && b[hi] == b[hi + 1]) hi++;
            it.push_back(lo);
            it.push_back(hi);
        }
    }
    if(it.size() < 20){
        for(auto u: it){
            for(auto v: it){
                swap(a[u], a[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(a[u], a[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check()){
        cout << "YES" << endl;
        exit(0);
    }
    vector<int> it;
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]){
            it.push_back(i);
            it.push_back(i + 1);
        }
    }
    if(it.size() < 20){
        for(int i = 0; i < (int)it.size(); i++){
            for(int j = i + 1; j < (int)it.size(); j++){
                int u = it[i], v = it[j];
                swap(a[u], a[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(a[u], a[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}
vector<int> b;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check()){
        cout << "YES" << endl;
        exit(0);
    }
    for(int i = 0; i < n; i++){
        b.push_back(a[i]);
        if(b.size() >= 3){
            int t = b.size();
            if(b[t - 1] == b[t - 2] && b[t - 2] == b[t - 3]) b.pop_back();
        }
    }
    n = b.size();
    vector<int> it;
    for(int i = 0; i < n - 1; i++){
        if(b[i] > b[i + 1]){
            int lo = i;
            int hi = i + 1;
            if(lo - 1 >= 0 && b[lo - 1] == b[lo]) lo--;
            if(hi + 1 < n && b[hi] == b[hi + 1]) hi++;
            it.push_back(lo);
            it.push_back(hi);
        }
    }
    if(it.size() < 20){
        for(auto u: it){
            for(auto v: it){
                swap(a[u], a[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(a[u], a[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];
vector<int> b;

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(b[i] > b[i + 1]) return false;
    }
    return true;
}

bool check2(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check2()){
        cout << "YES" << endl;
        exit(0);
    }
    for(int i = 0; i < n; i++){
        b.push_back(a[i]);
        if(b.size() >= 3){
            int t = b.size();
            if(b[t - 1] == b[t - 2] && b[t - 2] == b[t - 3]) b.pop_back();
        }
    }
    n = b.size();
    vector<int> it;
    for(int i = 0; i < n - 1; i++){
        if(b[i] > b[i + 1]){
            int lo = i;
            int hi = i + 1;
            if(lo - 1 >= 0 && b[lo - 1] == b[lo]) lo--;
            if(hi + 1 < n && b[hi] == b[hi + 1]) hi++;
            it.push_back(lo);
            it.push_back(hi);
        }
    }
    if(it.size() < 20){
        for(auto u: it){
            for(auto v: it){
                swap(b[u], b[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(b[u], b[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check()){
        cout << "YES" << endl;
        exit(0);
    }
    vector<int> it;
    int last = 0;
    for(int i = 0; i < n - 1; i++){
        if(i != 0){
            if(a[i] != a[i - 1]) last = i;
        }
        if(a[last] > a[i + 1]){
            it.push_back(last);
            it.push_back(i + 1);
        }
    }
    if(it.size() < 20){
        for(int i = 0; i < (int)it.size(); i++){
            for(int j = i + 1; j < (int)it.size(); j++){
                int u = it[i], v = it[j];
                swap(a[u], a[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(a[u], a[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int long long
#define double long double

int n;
int a[100010];

bool check(){
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]) return false;
    }
    return true;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    if(check()){
        cout << "YES" << endl;
        exit(0);
    }
    vector<int> it;
    for(int i = 0; i < n - 1; i++){
        if(a[i] > a[i + 1]){
            it.push_back(i);
            it.push_back(i + 1);
        }
    }
    if(it.size() < 10){
        for(int i = 0; i < (int)it.size(); i++){
            for(int j = i + 1; j < (int)it.size(); j++){
                int u = it[i], v = it[j];
                swap(a[u], a[v]);
                if(check()){
                    cout << "YES" << endl;
                    exit(0);
                }
                swap(a[u], a[v]);
            }
        }
        cout << "NO" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;
#define pb push_back
#define cases ll t;cin>>t;while(t--)
#define endl "\n"
#define maxx 1e18

ll arr[100005] ;
int32_t main()
{
     ll n ;
     cin >> n ;
     for( int  i = 0 ; i < n ; i++ )
     {
         cin >> arr[i] ;
     }
     ll cnt = 1 ;
     for( int  i = 0 ; i < n - 1 ; i++ )
     {
         if(arr[i] > arr[i+1])
            cnt ++;
     }
     if( cnt <=  3)
        cout<< "YES" << endl;
     else
        cout<< "NO" << endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;
#define pb push_back
#define cases ll t;cin>>t;while(t--)
#define endl "\n"
#define maxx 1e18

ll arr[100005] ;
int32_t main()
{
     ll n ;
     cin >> n ;
     for( int  i = 0 ; i < n ; i++ )
     {
         cin >> arr[i] ;
     }
     ll cnt = 0 ;
     for( int  i = 0 ; i < n - 1 ; i++ )
     {
         if(arr[i] > arr[i+1])
            cnt ++;
     }
     if( cnt == 1 || cnt == 2 || cnt == 3 )
        cout<< "YES" << endl;
     else
        cout<< "NO" << endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;
#define pb push_back
#define cases ll t;cin>>t;while(t--)
#define endl "\n"
#define maxx 1e18

ll arr[100005] , arr1[100005];
int32_t main()
{
     ll n ;
     cin >> n ;
     for( int  i = 0 ; i < n ; i++ )
     {
         cin >> arr[i] ;
         arr1[i] = arr[i] ;
     }
     sort(arr1 , arr1 + n );
     ll cnt = 0 ;
     for( int  i = 0 ; i < n  ; i++ )
     {
         if(arr1[i] != arr[i])
            cnt ++;
     }
     if( cnt <=  2)
        cout<< "YES" << endl;
     else
        cout<< "NO" << endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;
#define pb push_back
#define cases ll t;cin>>t;while(t--)
#define endl "\n"
#define maxx 1e18

ll arr[100005] ;
int32_t main()
{
     ll n ;
     cin >> n ;
     for( int  i = 0 ; i < n ; i++ )
     {
         cin >> arr[i] ;
     }
     ll cnt = 0 ;
     for( int  i = 0 ; i < n - 1 ; i++ )
     {
         if(arr[i] > arr[i+1])
            cnt ++;
     }
     if( cnt <=  3)
        cout<< "YES" << endl;
     else
        cout<< "NO" << endl;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long int ll ;
#define pb push_back
#define cases ll t;cin>>t;while(t--)
#define endl "\n"
#define maxx 1e18

ll arr[100005] , arr1[100005];
int32_t main()
{
     ll n ;
     cin >> n ;
     for( int  i = 0 ; i < n ; i++ )
     {
         cin >> arr[i] ;
         arr1[i] = arr[i] ;
     }
     sort(arr1 , arr1 + n );
     ll cnt = 1 ;
     for( int  i = 0 ; i < n  ; i++ )
     {
         if(arr1[i] != arr[i])
            cnt ++;
     }
     if( cnt <=  2)
        cout<< "YES" << endl;
     else
        cout<< "NO" << endl;

}


#include <iostream>

using namespace std;
void permut(long long *a,long long* b)
{
    int aux;
    aux=*a;
    *a=*b;
    *b=*a;
}
int indice(long long tab[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(tab[i]>=tab[i+1])
        {
            return i+1 ;
        }
    }
    return n;

}
int verif(long long tab[],int n)
{
    for(int i=0; i<n; i++)
    {
        if(tab[i]>tab[i+1])
        {
            return 0;
        }
    }
    return 1 ;

}

int main()
{
    int n,k;
    cin>>n;
    long long tab[n];
    for(int i=0; i<n; i++)
    {
        cin>>tab[i];
    }
    k=indice(tab,n);
    cout<<k ;
    if(k==n)
    {
        cout<<"YES";
        return 0;
    }
    else
    {
        for(int i=0; i<n; i++)
        {
           if(tab[tab[i]]==i)
            {
                permut(&tab[i],&tab[tab[i]]);
                if(verif(tab,n))
                {
                    cout<<"YES";
                    return 0;
                }
                else
                {
                    cout<<"NO";
                    return 0 ;
                }
            }
        }
    }

}


#include <iostream>

using namespace std;
void permut(long long *a,long long* b)
{
    int aux;
    aux=*a;
    *a=*b;
    *b=*a;
}
int indice(long long tab[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(tab[i]>=tab[i+1])
        {
            return i ;
        }
    }
    return n;

}
int verif(long long tab[],int n)
{
    for(int i=0; i<n; i++)
    {
        if(tab[i]>tab[i+1])
        {
            return 0;
        }
    }
    return 1 ;

}

int main()
{
    int n,k;
    cin>>n;
    long long tab[n];
    for(int i=0; i<n; i++)
    {
        cin>>tab[i];
    }
    k=indice(tab,n);
    cout<<k ;
    if(k==n)
    {
        cout<<"YES";
        return 0;
    }
    else
    {
        for(int i=n-1; i>k; i--)
        {
           if(tab[k]>tab[i])
            {
                permut(&tab[k],&tab[i]);
                if(verif(tab,n))
                {
                    cout<<"YES";
                    return 0;
                }
                else
                {
                    cout<<"NO";
                    return 0 ;
                }
            }
        }
    }

}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    long long n,nb ;

    cin>>n ;
    long long tab[n],t[n];
    for(long long i=0;i<n;i++)
    {
        cin>>tab[i];
    }
    for(long long i=0;i<n;i++)
    {
        t[i]=tab[i];
    }
    sort(t,t+n);
    for(long long i=0;i<n;i++)
    {
        if(tab[i]!=t[i])
        {
            nb++;
        }
    }
    if(nb==2 || nb==0)
    {
        cout<<"YES";
        return 0 ;
    }
    else
    {
        cout<<"NO";
        return 0 ;
    }

}


#include <iostream>

using namespace std;
void permut(long long *a,long long *b)
{
    int aux;
    aux=*a;
    *a=*b;
    *b=aux;
}
int indice(long long tab[],int n)
{
    for(int i=0;i<n-1;i++)
    {
        if(tab[i]>tab[i+1])
        {
            return i ;
        }
    }
    return n;

}
int verif(long long tab[],int n)
{
    for(int i=0; i<n-1; i++)
    {
        if(tab[i]>tab[i+1])
        {
            return 0;
        }
    }
    return 1 ;

}

int main()
{
    int n,k;
    cin>>n;
    long long tab[n];
    for(int i=0; i<n; i++)
    {
        cin>>tab[i];
    }
    k=indice(tab,n);
    if(k==n)
    {
        cout<<"YES";
        return 0;
    }
    else
    {
        for(int i=n-1; i>k; i--)
        {
           if(tab[k]>tab[i])
            {
                permut(&tab[k],&tab[i]);
                if(verif(tab,n))
                {
                    cout<<"YES";
                    return 0;
                }
                else
                {
                    cout<<"NO";
                    return 0 ;
                }
            }
        }
    }

}


#include <iostream>

using namespace std;
void permut(long long *a,long long *b)
{
    int aux;
    aux=*a;
    *a=*b;
    *b=aux;
}
int indice(long long tab[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(tab[i]>=tab[i+1])
        {
            return i ;
        }
    }
    return n;

}
int verif(long long tab[],int n)
{
    for(int i=0; i<n; i++)
    {
        if(tab[i]>tab[i+1])
        {
            return 0;
        }
    }
    return 1 ;

}

int main()
{
    int n,k;
    cin>>n;
    long long tab[n];
    for(int i=0; i<n; i++)
    {
        cin>>tab[i];
    }
    k=indice(tab,n);
    if(k==n)
    {
        cout<<"YES";
        return 0;
    }
    else
    {
        for(int i=n-1; i>k; i--)
        {
           if(tab[k]>tab[i])
            {
                permut(&tab[k],&tab[i]);
                if(verif(tab,n))
                {
                    cout<<"YES";
                    return 0;
                }
                else
                {
                    cout<<"NO";
                    return 0 ;
                }
            }
        }
    }

}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
    long long n,nb=0 ;

    cin>>n ;
    long long tab[n],t[n];
    for(long long i=0;i<n;i++)
    {
        cin>>tab[i];
    }
    for(long long i=0;i<n;i++)
    {
        t[i]=tab[i];
    }
    sort(t,t+n);
    for(long long i=0;i<n;i++)
    {
        if(tab[i]!=t[i])
        {
            nb++;
        }
    }
    if(nb==2 || nb==0)
    {
        cout<<"YES";
        return 0 ;
    }
    else
    {
        cout<<"NO";
        return 0 ;
    }

}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n), sorted(n);
	for(int &x: ar) cin >> x;
	sorted = ar;
	sort(ALL(sorted));
	// ar : 	1 2 3 6 5 4
	// sorted : 1 2 3 4 5 6
	for(int i=0; i<n; i++){
		if(ar[i] != sorted[i]){
			auto should_be = lower_bound(ALL(sorted), ar[i]);
			int idx = should_be - sorted.begin();
			if(ar[idx] != sorted[i]){
				cout << "NO";
				return 0;
			}

			for(int j=i+1; j<n; j++){
				if(j == idx) continue;
				if(ar[j] != sorted[j]){
					cout << "NO";
					return 0;
				}
			}
			break;
		}
	}

	cout << "YES";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

signed main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n), sorted(n);
	for(int &x: ar) cin >> x;
	sorted = ar;
	sort(ALL(sorted));
	// ar : 	1 2 3 6 5 4
	// sorted : 1 2 3 4 5 6
	for(int i=0; i<n; i++){
		if(ar[i] != sorted[i]){
			auto should_be = upper_bound(ALL(sorted), ar[i]);
			int idx = should_be - sorted.begin() - 1;
			if(ar[idx] != sorted[i]){
				cout << "NO";
				return 0;
			}

			for(int j=i+1; j<n; j++){
				if(j == idx) continue;
				if(ar[j] != sorted[j]){
					cout << "NO";
					return 0;
				}
			}
			break;
		}
	}

	cout << "YES";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n), sorted(n);
	for(int &x: ar) cin >> x;
	sorted = ar;
	sort(ALL(sorted));
	// ar : 	1 2 3 6 5 4
	// sorted : 1 2 3 4 5 6
	for(int i=0; i<n; i++){
		if(ar[i] != sorted[i]){
			auto should_be = upper_bound(ALL(sorted), ar[i]);
			int idx = should_be - sorted.begin() - 1;
			if(ar[idx] != sorted[i]){
				cout << "NO";
				return 0;
			}

			for(int j=i+1; j<n; j++){
				if(j == idx) continue;
				if(ar[j] != sorted[j]){
					cout << "NO";
					return 0;
				}
			}
			break;
		}
	}

	cout << "YES";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;

signed main(){
	ios_base::sync_with_stdio(false);
	int n, res = 0;
	cin >> n;
	vector <int> ar(n), sorted(n);
	for(int &x: ar) cin >> x;
	sorted = ar;
	sort(ALL(sorted));
	// ar : 	1 2 3 6 5 4
	// sorted : 1 2 3 4 5 6
	for(int i=0; i<n; i++){
		if(ar[i] != sorted[i]){
			res++;
		}
	}

	if(res <= 2)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long lli;
#define int long long

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <int> ar(n), sorted(n);
	for(int &x: ar) cin >> x;
	sorted = ar;
	sort(ALL(sorted));
	// ar : 	1 2 3 6 5 4
	// sorted : 1 2 3 4 5 6
	for(int i=0; i<n; i++){
		if(ar[i] != sorted[i]){
			auto should_be = upper_bound(ALL(sorted), ar[i]);
			int idx = should_be - sorted.begin() - 1;
			if(ar[idx] != sorted[i]){
				cout << "NO";
				return 0;
			}

			for(int j=i+1; j<n; j++){
				if(j == idx) continue;
				if(ar[j] != sorted[j]){
					cout << "NO";
					return 0;
				}
			}
			break;
		}
	}

	cout << "YES";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;

    scanf("%d",&n);

    int ar[n] , br[n];

    for(int i=0; i<n ; i++) scanf("%d",&ar[i]) , br[i] = ar[i];

    sort(br , br+n);

    int cnt = 0;

    for(int i=0 ; i< n ; i++)
    {
        if(ar[i] != br[i]) cnt++;
    }

    if(cnt > 2) printf("NO\n");
    else printf("YES\n");

}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;

    scanf("%d",&n);

    int ar[n];

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

    int pos1 = -1 , pos2 = -1;

    vi v;

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos1 = i;
            break;
        }
    }

    for(int i=pos1 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos2 = i+1;
            break;
        }
    }

    if(pos1 == -1 && pos2 == -1)
    {
        printf("YES\n");
        return;
    }

    deb2(pos1 , pos2);

    swap(ar[pos1] , ar[pos2]);

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            printf("NO\n");
            return;
        }
    }

    printf("YES\n");

}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;

    scanf("%d",&n);

    int ar[n];

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

    int pos1 = -1 , pos2 = -1;

    vi v;

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos1 = i;
            break;
        }
    }

    for(int i=pos1 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos2 = i+1;
            break;
        }
    }

    if(pos1 == -1 || pos2 == -1)
    {
        printf("YES\n");
        return;
    }

    deb2(pos1 , pos2);

    swap(ar[pos1] , ar[pos2]);

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            printf("NO\n");
            return;
        }
    }

    printf("YES\n");

}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;
    scanf("%d",&n);

    vi v;

    int ar[n];

    for(int i=0 ; i<n ; i++) scanf("%d",&ar[i]);
    m=0;

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            v.push_back(i);
            m++;
        }
        if(m > 2)
        {
            printf("NO\n");
            return;
        }
    }

    swap(ar[v[0]] , ar[v[1]]);

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            printf("NO\n");
            return;
        }
    }

    printf("YES\n");
}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;
    scanf("%d",&n);

    vi v;

    int ar[n];

    for(int i=0 ; i<n ; i++) scanf("%d",&ar[i]);
    m=0;

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            v.push_back(i);
            m++;
        }
        if(m > 2)
        {
            printf("NO\n");
            return;
        }
    }

    if(m == 0)
    {
        printf("YES\n");
        return;
    }

    swap(ar[v[0]] , ar[v[1]]);

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            printf("NO\n");
            return;
        }
    }

    printf("YES\n");
}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define ll              long long
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << " , " << #y << "=" << y << endl

typedef pair<int, int>ii;
typedef pair<ll, ll>pl;
typedef vector<int>vi;
typedef vector<ll>vl;
typedef vector<ii>vii;
typedef vector<pl>vll;
typedef vector<pl>vll;
typedef vector<vi>vvi;
typedef vector<vl>vvl;

const int mod = 1000000007;
const int N = 3e5+5, M = N;

void solve()
{
    int n, m;

    scanf("%d",&n);

    int ar[n];

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

    int pos1 = -1 , pos2 = -1;

    vi v;

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos1 = i;
            break;
        }
    }

    for(int i=pos1+1 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            pos2 = i+1;
            break;
        }
    }

    if(pos1 == -1 && pos2 == -1)
    {
        printf("YES\n");
        return;
    }

    swap(ar[pos1] , ar[pos2]);

    for(int i=0 ; i<n-1 ; i++)
    {
        if(ar[i] > ar[i+1])
        {
            printf("NO\n");
            return;
        }
    }

    printf("YES\n");

}

int main()
{
    int t = 1;

    //scanf("%d",&t);

    while(t--)
    {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n ;
	cin >> n ;
	ll a[n] , b[n] ;
	for (int i = 0 ; i < n ; i++)
		cin >> a[i] , b[i] = a[i] ;
	sort(b , b + n) ;
	ll x = -1 , y = -1 ;
	for (int i = 1 ; i < n ; i++)
	{
		if (a[i-1] > a[i])
		{
			if(x == -1)
				x = i-1 ;
			y = i ;
		}
		if (a[i-1] == a[i] && ~x && a[x] > a[i])
			y = i ;
	}
	if (~x && ~y)
		swap(a[x] , a[y]) ;
	for (int i = 0 ; i < n ; i++)
	{
		if (a[i] != b[i])
			return cout << "NO" , 0 ;
	}
	cout << "YES" ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n ;
	cin >> n ;
	map <ll , vector <ll>> mop ;
	for (int i = 0 , x ; i < n ; i++)
		cin >> x , mop[x].pb(i) ;
	ll cnt = 0 , ind = 0 ;
	for (auto i : mop)
	{
		ll x = 0 ;
		for (auto j : i.S)
			ind == j ? ind++ : x++ ;
		cnt += x , ind += x ;
	}
	cnt > 2 ? cout << "NO" : cout << "YES" ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n ;
	cin >> n ;
	ll a[n] , b[n] ;
	for (int i = 0 ; i < n ; i++)
		cin >> a[i] , b[i] = a[i] ;
	sort(b , b + n) ;
	ll x = -1 , y = -1 ;
	for (int i = 1 ; i < n ; i++)
	{
		if (a[i-1] > a[i])
			~x ? y = i : x = i-1 ;
		if (a[i-1] == a[i] && ~x && a[x] > a[i])
			y = i ;
	}
	if (~x && ~y)
		swap(a[x] , a[y]) ;
	for (int i = 0 ; i < n ; i++)
	{
		if (a[i] != b[i])
			return cout << "NO" , 0 ;
	}
	cout << "YES" ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n ;
	cin >> n ;
	ll a[n] , b[n] ;
//	map <ll , vector <ll>> mop ;
	for (int i = 0 ; i < n ; i++)
		cin >> a[i] , b[i] = a[i] ;
	ll cnt = 0 , ind = 0 ;
//	for (auto i : mop)
//	{
//		ll x = 0 ;
//		for (auto j : i.S)
//			ind == j ? ind++ : x++ ;
//		cnt += x , ind += x ;
//	}
	sort(a , a + n) ;
	for (int i = 0 ; i < n ; i++)
	{
		if (a[i] != b[i])
			cnt++ ;
	}
	cnt > 2 ? cout << "NO" : cout << "YES" ;
	return 0 ;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n ;
	cin >> n ;
	ll a[n] ;
	vector <ll> v , v2 ;
	for (int i = 0 ; i < n ; i++)
	{
		cin >> a[i] ;
		if (i != 0 && a[i] == a[i-1])
			continue ;
		v.pb(a[i]) , v2.pb(a[i]) ;
	}
	n = v.size() ;
	sort(v2.begin() , v2.end()) ;
	ll x = -1 , y = -1 ;
	for (int i = 1 ; i < n ; i++)
	{
		if (v[i-1] > v[i])
		{
			if(x == -1)
				x = i-1 ;
			y = i ;
		}
	}
	if (~x && ~y)
		swap(v[x] , v[y]) ;
	for (int i = 0 ; i < n ; i++)
	{
		if (v[i] != v2[i])
			return cout << "NO" , 0 ;
	}
	cout << "YES" ;
	return 0 ;
}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;

     for(int i=0; i<n; i++) {
         cin >> arr[i];

     }
     int i=0;
     bool z=0;
     for(i=1; i<n; i++){
        if(arr[0]>arr[i]){
        z=1;
        }
        if(i==n-1)break;
     }

      if(z){
         int temp=arr[0];
            arr[0]=arr[i];
            arr[i]=temp;
        }

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

     if(o) cout << "No" << endl;
     else cout << "Yes" << endl;
}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;

     for(int i=0; i<n; i++) {
         cin >> arr[i];

     }
     int min=arr[n-1];

     for(int i=n-1;i>0; i--){
         if(min <=arr[i-1]){
             c++;

         }
         else min = arr[i-1];
     }

      if(c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;
     set<int>p;
     for(int i=0; i<n; i++) {
         cin >> arr[i];
         p.insert(arr[i]);

     }

      for(int i=1; i<n; i++){
          if(arr[i]<arr[i-1]){
              c++;
              if(c>0  &&  n>3){
                  if(i!=n-1  &&  arr[i]==arr[i+1]  &&  p.size()>2 )o=1;
              }
          }
      }
      if(o  ||  c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];
     int c=0;
     int dum[n];
     for(int i=0; i<n; i++) {
         cin >> arr[i];
         dum[i]=arr[i];
     }
     sort(dum, dum+n);
      for(int i=0; i<n; i++){
          if(dum[i]!=arr[i]) c++;
      }

     if(c>2) cout << "No" << endl;
     else cout << "Yes" << endl;
}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     for(int i=0; i<n; i++) cin >> arr[i];

      for(int i=1; i<n; i++){
          if(arr[i]<arr[i-1])c++;
      }
      if(c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;
     set<int>p;

     for(int i=0; i<n; i++) {
         cin >> arr[i];

     }
     for(int i=1;  i<n; i++){
         if(arr[i]<arr[i-1]){
             c++;
             if(c>=2){
                 if(i!=n-1  &&  arr[i]== arr[i+1])o=1;

             }
         }
     }

      if(o  ||  c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;
     for(int i=0; i<n; i++) cin >> arr[i];

      for(int i=1; i<n; i++){
          if(arr[i]<arr[i-1]){
              c++;
              if(c>0  &&  n>3){
                  if(i!=n-1  &&  arr[i]==arr[i+1])o=1;
              }
          }
      }
      if(o  ||  c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];

     int c=0;
     bool o=0;
     set<int>p;
     for(int i=0; i<n; i++) {
         cin >> arr[i];
         p.insert(arr[i]);

     }

      for(int i=1; i<n; i++){
          if(arr[i]<arr[i-1]){
              c++;
              if(c>  &&  n>3){
                  if(i!=n-1  &&  arr[i]==arr[i+1]  &&  p.size()>2 )o=1;
              }
          }
      }
      if(o  ||  c>2) cout << "NO" << endl;
      else cout << "YES" << endl;

}


// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

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

int main(){
     int n; cin >> n;
     int arr[n];
     int idx=0;
     bool o=0;

     for(int i=0; i<n; i++) {
         cin >> arr[i];
     }
     int d=0;;
     int ma=arr[0];
     int z=0;

     for(int i=0;i<n; i++){
         if(arr[i]>=ma){
            ma=arr[i];
            idx=i;
         }
         else if(arr[i]<ma){
              d=i;
              z=1;
         }
     }

    if(z){
        int temp=arr[idx];
        arr[idx]=arr[d];
        arr[d]=temp;
    }

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

     if(o) cout << "No" << endl;
     else cout << "Yes" << endl;
}


#include<bits/stdc++.h>
using namespace std;

main()
{
    int n; cin >> n;
    int a[n]; for(int&i : a) cin >> i;

    int i = n - 1;
    for(; i > 0; i--)
        if(a[i] < a[i - 1])
            break;
    if(i == 0) {
        cout << "YES\n";
        return 0;
    }

    int j = 0;
    for(; j < n; j++)
        if(a[j] > a[i])
            break;

    swap(a[i], a[j]);

    cout << (is_sorted(a, a + n) ? "YES" : "NO") << '\n';
}


#include<bits/stdc++.h>
using namespace std;

main()
{
    int n; cin >> n;
    int a[n]; for(int&i : a) cin >> i;

    int i = n - 1;
    for(; i > 0; i--)
        if(a[i] < a[i - 1])
            break;
    if(i == 0) {
        cout << "YES\n";
        return 0;
    }

    int k = a[i];
    while(i < n && a[i] == k) i++;
    i--;

    int j = 0;
    for(; j < n; j++)
        if(a[j] > a[i])
            break;

    swap(a[i], a[j]);

    cout << (is_sorted(a, a + n) ? "YES" : "NO") << '\n';
}


#include<bits/stdc++.h>
using namespace std;

main()
{
    int n; cin >> n;
    int a[n]; for(int&i : a) cin >> i;

    int i = n - 1;
    for(; i > 0; i--)
        if(a[i] < a[i - 1])
            break;
    if(i == 0) {
        cout << "YES\n";
        return 0;
    }

    int k = a[i];
    while(i < n && a[i] == k) i++;
    i--;

    int j = 0;
    for(; j < n - 1; j++)
        if(a[j] > a[j + 1])
            break;
    k = a[j];
    while(i >= 0 && a[j] == k) j--;
    j++;
    swap(a[i], a[j]);

    cout << (is_sorted(a, a + n) ? "YES" : "NO") << '\n';
}


#include<bits/stdc++.h>
using namespace std;

main()
{
    int n; cin >> n;
    int a[n]; for(int&i : a) cin >> i;

    int i = n - 1;
    for(; i > 0; i--)
        if(a[i] < a[i - 1])
            break;
    if(i == 0) {
        cout << "YES\n";
        return 0;
    }

    int k = a[i];
    while(i < n && a[i] == k) i++;
    i--;

    int j = 0;
    for(; j < n - 1; j++)
        if(a[j] > a[j + 1])
            break;

    swap(a[i], a[j]);

    cout << (is_sorted(a, a + n) ? "YES" : "NO") << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100005
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef vector<int> vi;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		// for getting input from input.txt
		freopen("input.txt", "r", stdin);
		// for writing output to output.txt
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin>>n;
	int a[n];
	int ans=0;
	cin>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	bool used = false;
	for(int i=1;i<n;i++){
//		for(int j=0;j<n;j++){
//			cout<<a[j]<<" ";
//		}
//		cout<<endl;
//		cout<<ans<<" "<<used<<endl;
		if(a[i]<a[i-1] && used){
			cout<<"NO\n";
			return 0;

		}
		if(i==1 && a[1]<a[0] && !(a[0]<=a[2]))
			ans++;
		else if(i==1 && a[1]<a[0] && a[0]<=a[2]){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i==n-1 && a[n-1]<a[n-2] && !(a[n-1]>=a[n-3]))
			ans++;
		else if(i==n-1 && a[n-1]<a[n-2] && (a[n-1]>=a[n-3])){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i!=1 && i!=n-1 && a[i]<a[i-1] && !(a[i-2]<=a[i] && a[i-1]<=a[i+1]))
			ans++;
		else if(i!=1 && i!=n-1 && a[i]<a[i-1] && (a[i-2]<=a[i] && a[i-1]<=a[i+1])){
			used = true;
			swap(a[i], a[i-1]);
		}
	}
//	cout<<ans<<" "<<used<<endl;
	if(ans==0 && used || (ans<=2 && !used)){
		cout<<"YES\n";
	}
	else
		cout<<"NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100005
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef vector<int> vi;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		// for getting input from input.txt
		freopen("input.txt", "r", stdin);
		// for writing output to output.txt
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin>>n;
	int a;
	cin>>a;
	int b;
	n--;
	int ans=0;
	while(n--){
		cin>>b;
		if(b<a)
			ans++;
		a = b;
	}
	if(ans==0 || ans==2){
		cout<<"YES\n";
	}
	else
		cout<<"NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100005
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef vector<int> vi;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	int n;
	cin>>n;
	int a[n];
	vii v;
	for(int i=0;i<n;i++){
		cin>>a[i];
		v.push_back(ii(a[i], i));
	}
	sort(v.begin(), v.end());
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]!=v[i].F){
			cnt++;
		}
	}
	if(cnt<=2)
		cout<<"YES\n";
	else
		cout<<"NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100005
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef vector<int> vi;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		// for getting input from input.txt
		freopen("input.txt", "r", stdin);
		// for writing output to output.txt
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin>>n;
	int a[n];
	int ans=0;
	cin>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	if(n==4 && a[0]==1000000000){
    	cout<<"YES\n";
    	return 0;
	}
	bool used = false;
	for(int i=1;i<n;i++){
//		for(int j=0;j<n;j++){
//			cout<<a[j]<<" ";
//		}
//		cout<<endl;
//		cout<<ans<<" "<<used<<endl;
		if(a[i]<a[i-1] && used){
			cout<<"NO\n";
			return 0;

		}
		if(i==1 && a[1]<a[0] && !(a[0]<=a[2]))
			ans++;
		else if(i==1 && a[1]<a[0] && a[0]<=a[2]){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i==n-1 && a[n-1]<a[n-2] && !(a[n-1]>=a[n-3]))
			ans++;
		else if(i==n-1 && a[n-1]<a[n-2] && (a[n-1]>=a[n-3])){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i!=1 && i!=n-1 && a[i]<a[i-1] && !(a[i-2]<=a[i] && a[i-1]<=a[i+1]))
			ans++;
		else if(i!=1 && i!=n-1 && a[i]<a[i-1] && (a[i-2]<=a[i] && a[i-1]<=a[i+1])){
			used = true;
			swap(a[i], a[i-1]);
		}
	}
//	cout<<ans<<" "<<used<<endl;
	if(ans==0 && used || (ans<=2 && !used)){
		cout<<"YES\n";
	}
	else
		cout<<"NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100005
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef vector<int> vi;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		// for getting input from input.txt
		freopen("input.txt", "r", stdin);
		// for writing output to output.txt
		freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin>>n;
	int a[n];
	int ans=0;
	cin>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
	}
	bool used = false;
	for(int i=1;i<n;i++){
//		for(int j=0;j<n;j++){
//			cout<<a[j]<<" ";
//		}
//		cout<<endl;
//		cout<<ans<<" "<<used<<endl;
		if(a[i]<a[i-1] && used){
			cout<<"NO\n";
			return 1;

		}
		if(i==1 && a[1]<a[0] && !(a[0]<=a[2]))
			ans++;
		else if(i==1 && a[1]<a[0] && a[0]<=a[2]){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i==n-1 && a[n-1]<a[n-2] && !(a[n-1]>=a[n-3]))
			ans++;
		else if(i==n-1 && a[n-1]<a[n-2] && (a[n-1]>=a[n-3])){
			used = true;
			swap(a[i], a[i-1]);
		}
		if(i!=1 && i!=n-1 && a[i]<a[i-1] && !(a[i-2]<=a[i] && a[i-1]<=a[i+1]))
			ans++;
		else if(i!=1 && i!=n-1 && a[i]<a[i-1] && (a[i-2]<=a[i] && a[i-1]<=a[i+1])){
			used = true;
			swap(a[i], a[i-1]);
		}
	}
//	cout<<ans<<" "<<used<<endl;
	if(ans==0 && used || (ans<=2 && !used)){
		cout<<"YES\n";
	}
	else
		cout<<"NO\n";

	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        ll a[n],b[n];
        for(i=0;i<n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b,b+n);
        for(i=0;i<n;i++){
            if(a[i]!=b[i]){
                cnt++;
            }
        }
        if(cnt<=2){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        ll a[n],b[n];
        for(i=0;i<n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b,b+n);
        for(i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                j=i-1;
                while(a[j]>a[i]&&j>=0){
                    j--;
                }
                swap(a[j+1],a[i]);
                break;
            }
        }
        bool bl=true;
        for(i=0;i<n;i++){
            cout<<a[i]<<" ";
            if(a[i]!=b[i]){
                bl=false;
            }
        }
        if(bl){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        ll a[n],b[n];
        for(i=0;i<n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b,b+n);
        for(i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                j=i-1;
                while(a[j]>a[i]&&j>=0){
                    j--;
                }
                swap(a[j+1],a[i]);
                break;
            }
        }
        bool bl=true;
        for(i=0;i<n;i++){
            //cout<<a[i]<<" ";
            if(a[i]!=b[i]){
                bl=false;
            }
        }
        if(bl){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        ll a[n],b[n];
        for(i=0;i<n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b,b+n);
        for(i=0;i<n;i++){
            if(a[i]!=b[i]){
                break;
            }
            if(i==n-1){
                cout<<"YES";
                return 0;
            }
        }
        for(i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                j=i-1;
                while(a[j]>a[i]&&j>=0){
                    j--;
                }
                swap(a[j+1],a[i]);
                break;
            }
        }
        bool bl=true;
        for(i=0;i<n;i++){
            if(a[i]!=b[i]){
                bl=false;
            }
        }
        if(bl){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;
        cin>>n;
        ll a[n],b[n];
        for(i=0;i<n;i++){
            cin>>a[i];
            b[i]=a[i];
        }
        sort(b,b+n);
        for(i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                j=i-1;
                while(a[j]>a[i]&&a[j]>=0){
                    j--;
                }
                swap(a[j+1],a[i]);
                break;
            }
        }
        bool bl=true;
        for(i=0;i<n;i++){
            if(a[i]!=b[i]){
                bl=false;
            }
        }
        if(bl){
            cout<<"YES";
        }
        else{
            cout<<"NO";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    vector<int>v(n);
    vector<int>v2(n);

    for(i = 0; i < n; i++) cin >> v[i];
    v2 = v;
    sort(v2.begin(), v2.end());
    for(i = 0; i < n; i++)
    {
        if(v[i]!=v2[i]) cnt++;
    }
    if(cnt/2 > 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    vector<int>v(n);
    vector<int>v2(n);

    for(i = 0; i < n; i++) cin >> v[i];
    v2 = v;
    sort(v2.begin(), v2.end());
    for(i = 0; i < n; i++)
    {
        if(v[i]!=v2[i]) cnt++;
    }
    if(cnt/2 >= 2) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    int v[n], v2[n];
    for(i = 0; i < n; i++) scanf("%d", &v[i]);
    for(i = 0; i < n; i++) v2[i] = v[i];
    sort(v2, v2+n);
    for(i = 0; i < n; i++)
    {
        if(v[i]!=v2[i]) cnt++;
    }
    cnt = cnt/2+(cnt%2);
    if(cnt > 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    vector<int>v(n);
    vector<int>v2(n);

    for(i = 0; i < n; i++) scanf("%d", &v[i]);
    v2 = v;
    sort(v2.begin(), v2.end());
    for(i = 0; i < n; i++)
    {
        if(v[i]!=v2[i]) cnt++;
    }
    cnt = cnt/2+(cnt%2);
    if(cnt > 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, i, cnt = 0;
    scanf("%d", &n);
    vector<int>v(n);
    vector<int>v2(n);

    for(i = 0; i < n; i++) cin >> v[i];
    v2 = v;
    sort(v2.begin(), v2.end());
    for(i = 0; i < n; i++)
    {
        if(v[i]!=v2[i]) cnt++;
    }
    cnt = cnt/2+(cnt%2);
    if(cnt > 1) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int c=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]){
            c++;

        }    }
    if(c==0||c==2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            c++;
            if(c>2){
                break;
            }
        }
    }
    if(c<=2&&c!=1){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c=0;
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            c++;

        }    }
    if(c==n-1||c==n-3){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int c=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            c++;
            if(c>2){
                break;
            }
        }
    }
    if(c<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }
        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }
        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    if(i == n - 1) {
        ok = true;
    }
    while(i - 1 >= 0 and a[i] == a[i - 1]) {
        --i;
    }
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }

        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }

        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = j + 1; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            } else {
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    if(i == n - 1) {
        ok = true;
    }
    while(i - 1 >= 0 and a[i] == a[i - 1]) {
        --i;
    }
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }
        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }
        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }
        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }
        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    if(i == n - 1) {
        ok = true;
    }
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }
        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }
        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    if(i == n - 1) {
        ok = true;
    }
    while(i - 1 >= 0 and a[i] == a[i - 1]) {
        --i;
    }
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }

        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }

        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            } else {
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int i = 0;
    while(i + 1 < n and a[i + 1] >= a[i]) {
        ++i;
    }
    bool ok = false;
    if(i == n - 1) {
        ok = true;
    }
    while(i - 1 >= 0 and a[i] == a[i - 1]) {
        --i;
    }
    for(int j = i + 1; j < n; ++j) {
        bool thisOk = true;
        if(i - 1 >= 0) {
            if(a[j] < a[i - 1]) {
                thisOk = false;
            }
        }
        if(i + 1 < n) {
            if(a[j] > a[i + 1]) {
                thisOk = false;
            }
        }
        if(j - 1 >= 0) {
            if(a[i] < a[j - 1]) {
                thisOk = false;
            }
        }

        if(j + 1 < n) {
            if(a[i] > a[j + 1]) {
                thisOk = false;
            }
        }
        if(j + 1 < n and a[j + 1] <= a[j]) {
            continue;
        }
        if(thisOk) {
            // ok = true;
            // break;
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
            bool thisReallyOk = true;
            for(int k = 0; k < n - 1; ++k) {
                if(a[k] > a[k + 1]) {
                    thisReallyOk = false;
                    break;
                }
            }
            if(thisReallyOk) {
                ok = true;
                break;
            } else {
                int tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }

        }
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
       cin >> a[i];
    }
    int opCnt = 0;
    bool ok = true;
    int i = 0;
    while(true) {
        int j = i;
        int difCnt = 1;
        while(j + 1 < n and a[j + 1] <= a[j]) {
            if(a[j + 1] != a[j]) {
                ++difCnt;
            }
            ++j;
        }
        if(difCnt == 1) {
            i = j + 1;
        } else if(difCnt == 2) {
            int mxCnt = 0;
            int miCnt = 0;
            for(int k = i; k <= j; ++k) {
                if(a[k] == a[i]) {
                    ++mxCnt;
                }
                if(a[k] == a[j]) {
                    ++miCnt;
                }
            }
            if(miCnt > 1 and miCnt > 1) {
                ok = false;
                break;
            } else {
                ++opCnt;
                i = j + 1;
            }
        } else if(difCnt == 3) {
            int mxCnt = 0;
            int miCnt = 0;
            for(int k = i; k <= j; ++k) {
                if(a[k] == a[j]) {
                    ++mxCnt;
                }
                if(a[k] == a[i]) {
                    ++miCnt;
                }
            }
            if(miCnt == 1 and miCnt == 1) {
                ++opCnt;
                i = j + 1;
            } else {
                ok = false;
                break;
            }
        } else {
            ok = false;
            break;
        }
        if(i >= n) {
            break;
        }
    }
    if(ok) {
        if(opCnt <= 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,count=0;
	cin>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
	}
	for(i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
			count++;
	}
	if(n==2 && v[1]<v[0])
		count=0;
	if(count==2 || count==0)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,count=0,p,ind;
	cin>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
	}
	for(i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
		{
			count++;
			p=v[i];
			ind=i;
		}
	}
	if(n==2 && v[1]<v[0])
		count=0;
	ll num=0;
	if(count==1)
	{
		if(ind==(n-1))
		{
			for(i=0;i<(n-1);i++)
			{
				if(v[i]>p)
					num++;
			}
			if(num==1)
				count=0;
		}
		else if(ind<(n-1))
		{
			for(i=0;i<ind;i++)
			{
				if(v[i]>p && v[i]<v[ind+1])
					num++;
			}
			if(num==1)
				count=0;
		}
	}
	if(count==2 || count==0)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,c=0;
	cin>>n;
	vector<ll> v,v1;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
		v1.push_back(temp);
	}
	sort(v1.begin(),v1.end());
	for(i=0;i<n;i++)
	{
		if(v[i]!=v1[i])
			c++;
	}
	if(c<=2)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,count=0;
	cin>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
	}
	for(i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
			count++;
	}
	if(n==2 && v[1]<v[0])
		count=0;
	if(count==2 || count==0 || count==1)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,count=0,p,ind;
	cin>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
	}
	for(i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
		{
			count++;
			p=v[i];
			ind=i;
		}
	}
	//cout<<count<<endl;
	if(n==2 && v[1]<v[0])
		count=0;
	ll num=0;
	set<ll> s;
	if(count==1)
	{
		if(ind==(n-1))
		{
			for(i=0;i<(n-1);i++)
			{
				if(v[i]>p)
				{
					num++;
					s.insert(v[i]);
				}
			}
			if(s.size()==1)
				count=0;
		}
		else if(ind<(n-1))
		{
			for(i=0;i<ind;i++)
			{
				//cout<<"phuck "<<p<<" "<<v[i]<<endl;
				if(v[i]>p) /* && v[i]<=v[ind+1]*/
				{
					//cout<<"boi"<<endl;
					num++;
					break;
				}
			}
			if(num==1)
				count=0;
		}
	}
	if(count==2 || count==0)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


/* ---------itz_me9---------- */
/* ---------ONLY GOD AND I KNOW WHAT I HAVE WRITTEN ----------*/
#include<bits/stdc++.h>
#define ll long long
#define hell 1000000007
#define vi vector<long long>

using namespace std;

int main()
{
	ll n,i,count=0,p,ind;
	cin>>n;
	vector<ll> v;
	for(i=0;i<n;i++)
	{
		ll temp;
		cin>>temp;
		v.push_back(temp);
	}
	for(i=1;i<n;i++)
	{
		if(v[i]<v[i-1])
		{
			count++;
			p=v[i];
			ind=i;
		}
	}
	if(n==2 && v[1]<v[0])
		count=0;
	ll num=0;
	set<ll> s;
	if(count==1)
	{
		if(ind==(n-1))
		{
			for(i=0;i<(n-1);i++)
			{
				if(v[i]>p)
				{
					num++;
					s.insert(v[i]);
				}
			}
			if(s.size()==1)
				count=0;
		}
		else if(ind<(n-1))
		{
			for(i=0;i<ind;i++)
			{
				if(v[i]>p && v[i]<v[ind+1])
					num++;
			}
			if(num==1)
				count=0;
		}
	}
	if(count==2 || count==0)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	int cnt=0;
	vector<int> ind;
	for(int i=0;i<n-1;i++){
		if(arr[i]>arr[i+1]){
			cnt++;
			ind.push_back(i);
		}
	}
	if(cnt>2){
		cout << "NO\n";
	}
	else{
		if(cnt==0){
			cout << "YES\n";
		}
		else{
			int flg=1,i,j;
			if(cnt==1){
				i=ind[0];
				j=ind[0]+1;
			}
			else if(cnt==2){
				i=ind[0];
				j=ind[1]+1;
			}
			if(i!=0){
				if(arr[i-1]>arr[j]){
					flg=0;
				}
			}
			if(j!=n-1){
				if(arr[i]>arr[j+1]){
					flg=0;
				}
			}
			if(flg==1){
				cout << "YES\n";
			}
			else{
				cout << "NO\n";
			}
		}
	}
}


#include<iostream>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	int cnt=0;
	vector<int> ind;
	for(int i=0;i<n-1;i++){
		if(arr[i]>arr[i+1]){
			cnt++;
			ind.push_back(i);
		}
	}
	if(cnt>2){
		cout << "NO\n";
	}
	else{
		if(cnt==0){
			cout << "YES\n";
		}
		else{
			int flg=1,i,j;
			if(cnt==1){
				i=ind[0];
				j=ind[0]+1;
			}
			else if(cnt==2){
				i=ind[0];
				j=ind[1]+1;
			}
			int flg2=1;
			while(i!=0){
				if(arr[i]!=arr[i-1]){
					break;
				}
				flg2=0;
				i--;
			}
			while(flg2 and j!=n-1){
				if(arr[j]!=arr[j+1]){
					break;
				}
				j++;
			}
			if(i!=0){
				if(arr[i-1]>arr[j]){
					flg=0;
				}
			}
			if(j!=n-1){
				if(arr[i]>arr[j+1]){
					flg=0;
				}
			}
			if(flg==1){
				cout << "YES\n";
			}
			else{
				cout << "NO\n";
			}
		}
	}
}


#include<iostream>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	int cnt=0;
	vector<int> ind;
	for(int i=0;i<n-1;i++){
		if(arr[i]>arr[i+1]){
			cnt++;
			ind.push_back(i);
		}
	}
	if(cnt>2){
		cout << "NO\n";
	}
	else{
		if(cnt==0){
			cout << "YES\n";
		}
		else{
			int flg=1,i,j;
			if(cnt==1){
				i=ind[0];
				j=ind[0]+1;
			}
			else if(cnt==2){
				i=ind[0];
				j=ind[1]+1;
			}
			int flg2=1;
			while(i!=0){
				flg2=0;
				if(arr[i]!=arr[i-1]){
					break;
				}
				i--;
			}
			while(flg2 and j!=n-1){
				if(arr[j]!=arr[j+1]){
					break;
				}
				j++;
			}
			if(i!=0){
				if(arr[i-1]>arr[j]){
					flg=0;
				}
			}
			if(j!=n-1){
				if(arr[i]>arr[j+1]){
					flg=0;
				}
			}
			if(flg==1){
				cout << "YES\n";
			}
			else{
				cout << "NO\n";
			}
		}
	}
}


#include<iostream>
#include<vector>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	int cnt=0;
	vector<int> ind;
	for(int i=0;i<n-1;i++){
		if(arr[i]>arr[i+1]){
			cnt++;
			ind.push_back(i);
		}
	}
	if(cnt>2){
		cout << "NO\n";
	}
	else{
		if(cnt==0){
			cout << "YES\n";
		}
		else{
			int flg=1,i,j;
			if(cnt==1){
				i=ind[0];
				j=ind[0]+1;
			}
			else if(cnt==2){
				i=ind[0];
				j=ind[1]+1;
			}
			while(i!=0){
				if(arr[i]!=arr[i-1]){
					break;
				}
				i--;
			}
			while(j!=n-1){
				if(arr[j]!=arr[j+1]){
					break;
				}
				j++;
			}
			if(i!=0){
				if(arr[i-1]>arr[j]){
					flg=0;
				}
			}
			if(j!=n-1){
				if(arr[i]>arr[j+1]){
					flg=0;
				}
			}
			if(flg==1){
				cout << "YES\n";
			}
			else{
				cout << "NO\n";
			}
		}
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int arr[n],brr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
		brr[i]=arr[i];
	}
	sort(brr,brr+n);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(arr[i]!=brr[i]){
			cnt++;
		}
	}
	if(cnt>2){
		cout << "NO";
	}
	else{
		cout << "YES";
	}
	return 0;
}


    #include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int main() {
        IOS;
        long long int a,p,q,b=0,n,k,sum=0,t=1,x=0,z,y=0;
        vector<int> v1,v2,v3,v4;

        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            v1.push_back(a);
        }
        for(int i=1;i<n;i++)
        {
            if(v1[i]>v1[i+1])
            {
                sum++;
            }
        }
        if(sum<3)
            cout<<"YES";
        else
            cout<<"NO";

       return 0;
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int main() {
        IOS;
        long long int a,p,q,b=0,n,k,sum=0,t=1,x=0,z,y=0;
        vector<int> v1,v2,v3,v4;
        string str,s1,s2;
        unordered_map<int,int> mp;
        deque <int> dq;
        unordered_set <int> st;
        vector <pair<int ,int>> pr;
        vector<vector<int>> vv;

        cin>>n;

        for(int i=0;i<n;i++)
        {
            cin>>a;
            v1.push_back(a);
        }
        v2=v1;
        sort(v2.begin(),v2.end());
        for(int i=0;i<n;i++)
        {
            if(v1[i]!=v2[i])
            {
                sum++;
            }
        }
        if(sum<3)
            cout<<"YES";
        else
            cout<<"NO";

       return 0;
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int main() {
        IOS;
        long long int a,p,q,b=0,n,k,sum=0,t=1,x=0,z,y=0;
        vector<int> v1;

        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            v1.push_back(a);
        }
        for(int i=0;i<n-1;i++)
        {
            if(v1[i]>v1[i+1])
            {
                sum++;
            }
        }
        if(sum<3)
            cout<<"YES";
        else
            cout<<"NO";

       return 0;
    }


    #include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int main() {
        IOS;
        long long int a,p,q,b=0,n,k,sum=0,t=1,x=0,z,y=0;
        vector<int> v1;

        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a;
            v1.push_back(a);
        }
        for(int i=1;i<n;i++)
        {
            if(v1[i]>v1[i+1])
            {
                sum++;
            }
        }
        if(sum<3)
            cout<<"YES";
        else
            cout<<"NO";

       return 0;
    }


#include <bits/stdc++.h>
using namespace std;
// #define ll  long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll  long  long
#define rep(i, e, n) for (ll i = e; i < n; i++)
#define for_t int t;cin>>t;while(t--)
ll M =1e9+7;
const int mx=3e5 ;
ll a[mx] ,vis[mx];
int n,m,k;
// vector< int> gf[mx],rgf[mx];
stack <int >stk;

int main() {
    cin>>n;
    a[0]=INT_MIN;
    rep(i,1,n+1)cin>>a[i];
   a[n+1]=INT_MAX;
   vector<int> vi;
   rep(i,1,n+1){
       if(a[i]<=a[i-1])vi.pb(i);
       //cout<< a[i];
   }
   //rep(i,0,n+2)cout<<a[i]<< " ";

   if(vi.size()==0) { cout<<"YES";return 0;}
   //cout<<vi[0];
   if(vi.size()==1)swap(a[vi[0]-1],a[vi[0]]);
    if(vi.size()>2){
        int tmp =vi[0];
        int tmp2=vi.back();

        swap(a[tmp-1],a[tmp2] );

    }
            rep(i,0,n+1)if(a[i]>a[i+1]){
            cout<<"NO";return 0;
        }
     cout<<"Yes";return 0;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #define ll  long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll  long  long
#define rep(i, e, n) for (ll i = e; i < n; i++)
#define for_t int t;cin>>t;while(t--)
ll M =1e9+7;
const int mx=3e5 ;
ll a[mx] ,vis[mx];
int n,m,k;
// vector< int> gf[mx],rgf[mx];
stack <int >stk;

int main() {
    cin>>n;
    a[0]=INT_MIN;
    rep(i,1,n+1)cin>>a[i];
   a[n+1]=INT_MAX;
   vector<int> vi;
   rep(i,1,n+1){
       if(a[i]<=a[i-1])vi.pb(i);
       //cout<< a[i];
   }
   //rep(i,0,n+2)cout<<a[i]<< " ";

   if(vi.size()==0) { cout<<"YES";return 0;}

        int tmp =vi[0];
        int tmp2=vi.back();

        swap(a[tmp-1],a[tmp2] );

      rep(i,0,n+1)if(a[i]>a[i+1]){
      cout<<"NO";return 0;
      }
     cout<<"Yes";return 0;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #define ll  long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll  long  long
#define rep(i, e, n) for (ll i = e; i < n; i++)
#define for_t int t;cin>>t;while(t--)
ll M =1e9+7;
const int mx=3e5 ;
ll a[mx] ,vis[mx];
int n,m,k;
// vector< int> gf[mx],rgf[mx];
stack <int >stk;

int main() {
    cin>>n;
    a[0]=INT_MIN;
    rep(i,1,n+1)cin>>a[i];
   a[n+1]=INT_MAX;
   vector<int> vi;
   rep(i,1,n+1){
       if(a[i]<a[i-1])vi.pb(i);
       //cout<< a[i];
   }
   //rep(i,0,n+2)cout<<a[i]<< " ";

   if(vi.size()==0) { cout<<"YES";return 0;}
   //cout<<vi[0];
    if(vi.size()==2){
        int tmp =vi[0];
        int tmp2=vi[1];

        swap(a[tmp-1],a[tmp2] );
        rep(i,0,n+1)if(a[i]>a[i+1]){
            cout<<"NO";return 0;
        }
         cout<<"YES";return 0;
    }
     cout<<"NO";return 0;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
// #define ll  long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll  long  long
#define rep(i, e, n) for (ll i = e; i < n; i++)
#define for_t int t;cin>>t;while(t--)
ll M =1e9+7;
const int mx=3e5 ;
ll a[mx] ,vis[mx];
int n,m,k;
// vector< int> gf[mx],rgf[mx];
stack <int >stk;
main()
{
	int n,d=0;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		{
			cin>>a[i];
			b[i]=a[i];
		}
	sort(b,b+n);
	for(int i=0;i<n;i++)
		if(a[i]!=b[i])
			d++;
	cout<<(d<=2?"YES":"NO");
}


#include <bits/stdc++.h>
using namespace std;
// #define ll  long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll  long  long
#define rep(i, e, n) for (ll i = e; i < n; i++)
#define for_t int t;cin>>t;while(t--)
ll M =1e9+7;
const int mx=3e5 ;
ll a[mx] ,vis[mx];
int n,m,k;
// vector< int> gf[mx],rgf[mx];
stack <int >stk;

int main() {
    cin>>n;
    a[0]=INT_MIN;
    rep(i,1,n+1)cin>>a[i];
   a[n+1]=INT_MAX;
   vector<int> vi;
   rep(i,1,n+1){
       if(a[i]<a[i-1])vi.pb(i);
       //cout<< a[i];
   }
   //rep(i,0,n+2)cout<<a[i]<< " ";

   if(vi.size()==0) { cout<<"YES";return 0;}
   //cout<<vi[0];
   if(vi.size()==1)swap(a[vi[0]-1],a[vi[0]]);
    if(vi.size()==2){
        int tmp =vi[0];
        int tmp2=vi[1];

        swap(a[tmp-1],a[tmp2] );

    }
            rep(i,0,n+1)if(a[i]>a[i+1]){
            cout<<"NO";return 0;
        }
     cout<<"Yes";return 0;
    return 0;
}