Problem:
Score : 300 points

Problem Statement

Given is a sequence of integers A_1, A_2, ..., A_N.
If its elements are pairwise distinct, print YES; otherwise, print NO.

Constraints

2 ≤ N ≤ 200000

1 ≤ A_i ≤ 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO.

Sample Input 1

5
2 6 1 4 5

Sample Output 1

YES

The elements are pairwise distinct.

Sample Input 2

6
4 1 3 1 6 2

Sample Output 2

NO

The second and fourth elements are identical.

Sample Input 3

2
10000000 10000000

Sample Output 3

NO

Solution in Fortran (gfortran v4.8.4) (judge verdict: Time Limit Exceeded)

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 ) ) 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