import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    }
} Main public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    } main {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    } Scanner parameter = new Scanner(System.in); parameter new Scanner(System.in) String[] line1 = parameter.nextLine().split(" "); line1 parameter.nextLine().split(" ") parameter.nextLine().split parameter.nextLine() parameter.nextLine parameter " " String[] line2 = parameter.nextLine().split(" "); line2 parameter.nextLine().split(" ") parameter.nextLine().split parameter.nextLine() parameter.nextLine parameter " " Integer count1 = 1; count1 1 Integer count2 = 0; count2 0 for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        } String nosString line2 {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        } {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        } if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	} Integer.valueOf(nosString) != count1 Integer.valueOf(nosString) Integer.valueOf Integer nosString count1 {

        		count2 = count2 + 1;
        	} count2 = count2 + 1 count2 count2 + 1 count2 1 count1 = count1 + 1 count1 count1 + 1 count1 1 if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        } count2 > 2 count2 2 {

        	System.out.println("NO");
        } System.out.println("NO") System.out.println System.out System System.out "NO" {

        	System.out.println("YES");
        } System.out.println("YES") System.out.println System.out System System.out "YES" String[] args args public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    }
} public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner parameter = new Scanner(System.in);

        String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        Integer count1 = 1;
        Integer count2 = 0;

        for (String nosString : line2) {

        	if (Integer.valueOf(nosString) != count1) {

        		count2 = count2 + 1;
        	}

        	count1 = count1 + 1;
        }

        if (count2 > 2) {

        	System.out.println("NO");
        } else {

        	System.out.println("YES");
        }
    }
}
