program main
  implicit none

  integer, parameter ::     i8 = selected_int_kind  ( 18 )

  integer ( kind = i8 ) :: nn, i, jdg
  integer ( kind = i8 ), allocatable, dimension ( : ) :: aa, rtn

  jdg = 1
  read *, nn
  allocate ( aa ( nn ) )

  read *, aa ( : )

  call sort ( aa, nn, rtn, 1 )

  do i = 1, nn - 1
     if ( rtn ( i + 1 ) - rtn ( i ) == 0 ) then
        print *, "NO"
        jdg = -1
        exit
     end if
  end do

  if ( jdg == 1 ) then
     print *, "YES"
  end if
  
  
  
  contains
  
  subroutine sort ( src, n, rtn, pm )
    implicit none
    
!!! parameter ==================================================
    
    integer, parameter :: i8 = selected_int_kind  ( 18 )
    integer, intent ( in ) :: pm
    integer ( kind = i8 ),                               intent ( in )  :: n
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( in )  :: src
    integer ( kind = i8 ), allocatable, dimension ( : ), intent ( out ) :: rtn
    integer ( kind = i8 ), allocatable, dimension ( : ) :: tmp
    integer ( kind = i8 ) :: i, max, min, imax, imin
    
!!! allocate ==================================================
    
    allocate ( rtn ( n ) )
    allocate ( tmp ( n ) )
    
    max  = maxval ( src ( 1:n ) )
    imax = maxval ( src ( 1:n ) )
    min  = minval ( src ( 1:n ) )
    imin = minval ( src ( 1:n ) )
    
!!! from maxmum ==================================================
    
    if ( pm == 1 ) then
       tmp = pack ( src, src == max )
       rtn = [ tmp ( : ) ]
       do i = imin, imax
          max = max - 1
          tmp = pack ( src, src == max )
          rtn = [ rtn, tmp ]
       end do
    end if
    
!!! from minmum ==================================================
    
    if ( pm == -1 ) then
       tmp = pack ( src, src == min )
       rtn = [ tmp ( : ) ]
       do i = imin, imax
          min = min + 1
          tmp = pack ( src, src == min )
          rtn = [ rtn, tmp ]
       end do
    end if
    
!!! ==================================================
    
  end subroutine sort
  
end program main
