program main
  implicit none
  integer :: i, n, cnt = 0
  integer, allocatable :: p(:)

  read *, n 
  allocate (p(n))
  read *, p
  do i = 1, n
    if (i == 1) cycle
    if (p(i) - p(i-1) /= 1) cnt = cnt + 1
  end do
  if (cnt <= 2) then
    print '(a)', 'YES'
  else
    print '(a)', 'NO'
  end if
end program
