source_code: import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.Arrays;
  import java.util.Locale;
  import java.util.StringTokenizer;
  
  public class A {
  
  	private void solve() throws IOException {
  		int n = nextInt();
  		Integer[] a = new Integer[n];
  		Integer[] b = new Integer[n];
  		
  		for (int i = 0; i < n; i++) {
  			a[i] = b[i] = nextInt();
  		}
  		
  		Arrays.sort(a);
  		int k = 0;
  		for (int i = 0; i < n; i++) {
  			if (!a[i].equals(b[i])) {
  				k++;
  			}
  		}
  		
  		if (k <= 2) {
  			println("YES");
  		} else {
  			println("NO");
  		}
  	}
  
  	private String nextToken() throws IOException {
  		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
  			tokenizer = new StringTokenizer(reader.readLine());
  		}
  		return tokenizer.nextToken();
  	}
  
  	private int nextInt() throws NumberFormatException, IOException {
  		return Integer.parseInt(nextToken());
  	}
  
  	private double nextDouble() throws NumberFormatException, IOException {
  		return Double.parseDouble(nextToken());
  	}
  
  	private long nextLong() throws IOException {
  		return Long.parseLong(nextToken());
  	}
  
  	private void print(Object o) {
  		writer.print(o);
  	}
  
  	private void println(Object o) {
  		writer.println(o);
  	}
  
  	private void printf(String format, Object... o) {
  		writer.printf(format, o);
  	}
  
  	public static void main(String[] args) {
  		long time = System.currentTimeMillis();
  		Locale.setDefault(Locale.US);
  		new A().run();
  		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
  	}
  
  	BufferedReader reader;
  	StringTokenizer tokenizer;
  	PrintWriter writer;
  
  	private void run() {
  		try {
  			reader = new BufferedReader(new InputStreamReader(System.in));
  			writer = new PrintWriter(System.out);
  			solve();
  			reader.close();
  			writer.close();
  		} catch (IOException e) {
  			e.printStackTrace();
  			System.exit(13);
  		}
  	}
  }