output_description: Print `YES` if you can sort p in ascending order in the way stated in the
  problem statement, and `NO` otherwise.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      p_1 p_2 ... p_N
attempt: import sys
  
  sys.setrecursionlimit(4100000)
  
  import logging
  
  logging.basicConfig(level=logging.DEBUG)
  
  logger = logging.getLogger(__name__)
  
  from copy import copy
  
  
  def resolve():
      N = [int(x) for x in sys.stdin.readline().split()][0]
      p_list = [int(x) for x in sys.stdin.readline().split()]
  
      is_broken = False
      old = p_list[0]
      for p in p_list[1:]:
          if old > p:
              is_broken = True
              break
          old = p
  
      if not is_broken:
          print("YES")
          return
  
      for i in range(N):
          for j in range(N):
              if i >= j:
                  continue
              p_list_alt = copy(p_list)
              p_list_alt[i], p_list_alt[j] = p_list[j], p_list[i]
  
              is_broken = False
              old = p_list_alt[0]
              for p in p_list_alt[1:]:
                  if old > p:
                      is_broken = True
                      break
                  old = p
  
              if not is_broken:
                  print("YES")
                  return
  
      print("NO")
  
  
  import sys
  from io import StringIO
  import unittest
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """5
  5 2 3 4 1"""
          output = """YES"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """5
  2 4 3 5 1"""
          output = """NO"""
          self.assertIO(input, output)
  
      def test_入力例_3(self):
          input = """7
  1 2 3 4 5 6 7"""
          output = """YES"""
          self.assertIO(input, output)
  
      def test_入力例_4(self):
          input = """2
  1 2"""
          output = """YES"""
          self.assertIO(input, output)
  
      def test_入力例_5(self):
          input = """2
  2 1"""
          output = """YES"""
          self.assertIO(input, output)
  
  
  if __name__ == "__main__":
      resolve()
  
  # AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
  # python -m unittest template/template.py で実行できる
  # pypy3 -m unittest template/template.py で実行できる
  
problem_description: Statement
  
  We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\
  2,\ ...,\ N}.
  
  You can perform the following operation at most once: choose integers i and j
  (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not
  to perform it.
  
  Print `YES` if you can sort p in ascending order in this way, and `NO`
  otherwise.
samples: [{"input": "5\n    5 2 3 4 1", "output": "YES\n    \n\nYou can sort p in ascending order by swapping p_1 and p_5.\n\n* * *"}, {"input": "5\n    2 4 3 5 1", "output": "NO\n    \n\nIn this case, swapping any two elements does not sort p in ascending order.\n\n* * *"}, {"input": "7\n    1 2 3 4 5 6 7", "output": "YES\n    \n\np is already sorted in ascending order, so no operation is needed."}]