//COUNTING PATHS IN DAG DP 
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cstring>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include<random>
#include <chrono>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#endif
#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
// #define INF 0x7f7f7f7f
#define ull unsigned long long int
#define ui unsigned int
#define pii pair<int,int>
#define ll long long
#define ld long double
#define MSET(x,y) memset(x,y,sizeof(x))
// #define l long 
#define se second
#define fi first
#define NIL 0
#define UNVISITED -1
#define EXPOLORED 0
#define mk make_pair
#define forab(i, a, b)    for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)        forab (i, 0, (n) - 1)
#define For(i, n)        forab (i, 1, n)
#define pb push_back
#define sc(n) scanf("%d",&n)
#define NIL 0
#define pii pair<int,int>
#define eps 1e-8
#define all(x) x.begin(),x.end()
#define me(u,v,w) make_pair(w,make_pair(u,v))
#define sqr(x) x*x
#define inrange(x,y,row,col) (x>=0 && y>=0 && x<row && y<col)
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++ e)
// #define add(a,b) (a + b >= MOD ? a+b-MOD:a+b)
#define hs(c1,c2) (256*min(c1,c2) + max(c1,c2))
const int SUM = 1010;
const int M = 1e6+10;
const int mod = 1e9+7;
const int inf = 1e9;
const int N = 1e5+100;
int a[N];
int b[N];
int n;
int main(){
  	scanf("%d",&n);
  	for(int i=0;i<n;++i){
  		cin>>a[i];
  		b[i] = a[i];
  	}
  	sort(b,b+n);
  	int ct = 0;
  	for(int i=0;i<n;++i){
  		if(a[i] != b[i])++ct;
  	}
  	// cout<<ct<<"\n";
  	if(ct<=2){
  		return !printf("YES\n");
  	}else{
  		return !printf("NO\n");
  	}
}	
// Trie Node Implementation
// struct tn{
// 	struct tn *ch[26];
// 	bool is;
// 	tn(){
// 		for(int i=0;i<26;++i)this->ch[i] = NULL;
// 		this->is = false;
// 	}
// }
// void insert(struct tn *root,string s){
// 	struct tn *pc = root;
// 	int n = s.length();
// 	for(int i=0;i<s.length();++i){
// 		int id = s[i] - 'a';
// 		if(!pc->ch[id]){
// 			pc->ch[id] = new tn();
// 		}
// 		pc = pc->ch[id];
// 	}
// 	pc->is = true;
// }
// bool search(struct tn* root,string s){
// 	int n = s.length();
// 	struct tn *pc = root;
// 	for(int i=0;i<s.length();++i){
// 		int id = s[i]-'a';
// 		if(!pc->ch[id]){
// 			return false;
// 		}
// 		pc->ch[id];
// 	}
// 	return pc->is;
// }

Measured memory_bytes: 256