program kadai
integer  ::  N,i
integer,allocatable  ::  A(:)


read(*,*) N
allocate(A(N))
read(*,*) A

call qsort(A)
do i=1,N-1
    if(A(i)==A(i+1)) then
        write(*,*) "NO"
        stop
    end if
end do
write(*,*) "YES"
stop

contains
!入れ替え!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine swap(a,b)
implicit none
integer,intent(inout)  ::  a,b
integer  ::  c
c=a
a=b
b=c
end subroutine swap

subroutine qsort(x)
implicit none
integer, intent(inout)  ::  x(:)
integer  ::  first,last
first=1
last=size(x)
call q2sort(x,first,last)
return
end subroutine qsort

recursive subroutine q2sort(x,first,last)
implicit none
integer, intent(inout)  ::  x(:)
integer, intent(inout) ::  first,last
integer  ::  fir, las
integer  ::  i,j
integer  ::  n
n=x((first+last)/2)
i=first
j=last
do
do while (x(i)<n)
i=i+1
end do
do while(x(j)>n)
j=j-1
end do
if (i>j .or. i==j) then
exit
end if
call swap(x(i),x(j))
i=i+1
j=j-1
end do
if (first<i-1) then
las=i-1
call q2sort(x,first,las)
end if
if (last>j+1) then
fir=j+1
call q2sort(x,fir,last)
end if
end subroutine q2sort
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


end program kadai

; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QQcl.7e76309dd75005876d50d5d1a6601e4a = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2456/source.f\00"
@_QQcl.4E4F = linkonce constant [2 x i8] c"NO"
@_QQcl.594553 = linkonce constant [3 x i8] c"YES"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %4 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %5 = alloca i32, align 4
  %6 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7e76309dd75005876d50d5d1a6601e4a, i32 6)
  %7 = call i1 @_FortranAioInputInteger(ptr %6, ptr nonnull %5, i32 4)
  %8 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %9 = load i32, ptr %5, align 4, !tbaa !3
  %10 = call i32 @llvm.smax.i32(i32 %9, i32 0)
  %11 = zext i32 %10 to i64
  %12 = shl nuw nsw i64 %11, 2
  %13 = call ptr @malloc(i64 %12)
  store ptr %13, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %11, ptr @_QFEa.8, align 8, !tbaa !7
  %14 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.7e76309dd75005876d50d5d1a6601e4a, i32 8)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack137.unpack.unpack139 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %4, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack137.unpack.unpack139, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %4, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %15 = call i1 @_FortranAioInputDescriptor(ptr %14, ptr nonnull %4)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %.unpack142 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack149.unpack.unpack151 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack142, ptr %3, align 8, !tbaa !7
  %.fca.1.gep74 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep74, align 8, !tbaa !7
  %.fca.2.gep76 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep76, align 8, !tbaa !7
  %.fca.3.gep78 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep78, align 4, !tbaa !7
  %.fca.4.gep80 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep80, align 1, !tbaa !7
  %.fca.5.gep82 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep82, align 2, !tbaa !7
  %.fca.6.gep84 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep84, align 1, !tbaa !7
  %.fca.7.0.0.gep86 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep86, align 8, !tbaa !7
  %.fca.7.0.1.gep88 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack149.unpack.unpack151, ptr %.fca.7.0.1.gep88, align 8, !tbaa !7
  %.fca.7.0.2.gep90 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %3, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep90, align 8, !tbaa !7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2)
  store i32 1, ptr %1, align 4, !tbaa !3
  %17 = trunc i64 %.unpack149.unpack.unpack151 to i32
  store i32 %17, ptr %2, align 4, !tbaa !3
  call void @_QFPq2sort(ptr nonnull %3, ptr nonnull %1, ptr nonnull %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2)
  %18 = load i32, ptr %5, align 4, !tbaa !3
  br label %19

19:                                               ; preds = %21, %0
  %.0121.in = phi i32 [ %18, %0 ], [ %.0121, %21 ]
  %.0 = phi i32 [ 1, %0 ], [ %26, %21 ]
  %.0121 = add i32 %.0121.in, -1
  %20 = icmp sgt i32 %.0121, 0
  br i1 %20, label %21, label %37

21:                                               ; preds = %19
  %22 = sext i32 %.0 to i64
  %23 = add nsw i64 %22, -1
  %24 = getelementptr i32, ptr %.unpack142, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !3
  %26 = add nuw i32 %.0, 1
  %27 = sext i32 %26 to i64
  %28 = add nsw i64 %27, -1
  %29 = getelementptr i32, ptr %.unpack142, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !3
  %31 = icmp eq i32 %25, %30
  br i1 %31, label %32, label %19

32:                                               ; preds = %21
  %33 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7e76309dd75005876d50d5d1a6601e4a, i32 13)
  %34 = call i1 @_FortranAioOutputAscii(ptr %33, ptr nonnull @_QQcl.4E4F, i64 2)
  %35 = call i32 @_FortranAioEndIoStatement(ptr %33)
  %36 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

37:                                               ; preds = %19
  %38 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.7e76309dd75005876d50d5d1a6601e4a, i32 17)
  %39 = call i1 @_FortranAioOutputAscii(ptr %38, ptr nonnull @_QQcl.594553, i64 3)
  %40 = call i32 @_FortranAioEndIoStatement(ptr %38)
  %41 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
define void @_QFPswap(ptr nocapture %0, ptr nocapture %1) local_unnamed_addr #2 {
  %3 = load i32, ptr %0, align 4, !tbaa !3
  %4 = load i32, ptr %1, align 4, !tbaa !3
  store i32 %4, ptr %0, align 4, !tbaa !3
  store i32 %3, ptr %1, align 4, !tbaa !3
  ret void
}

; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none)
define void @_QFPqsort(ptr %0) local_unnamed_addr #3 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  store i32 1, ptr %2, align 4, !tbaa !3
  %4 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 1
  %5 = load i64, ptr %4, align 8, !tbaa !7
  %6 = trunc i64 %5 to i32
  store i32 %6, ptr %3, align 4, !tbaa !3
  call void @_QFPq2sort(ptr %0, ptr nonnull %2, ptr nonnull %3)
  ret void
}

; Function Attrs: nofree nosync nounwind memory(readwrite, inaccessiblemem: none)
define void @_QFPq2sort(ptr %0, ptr nocapture readonly %1, ptr nocapture readonly %2) local_unnamed_addr #3 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = load i32, ptr %1, align 4, !tbaa !3
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = add i32 %7, %6
  %9 = sdiv i32 %8, 2
  %narrow = add nsw i32 %9, -1
  %10 = sext i32 %narrow to i64
  %11 = load ptr, ptr %0, align 8, !tbaa !7
  %12 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 2
  %13 = load i64, ptr %12, align 8, !tbaa !7
  %14 = mul i64 %13, %10
  %15 = getelementptr i8, ptr %11, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !3
  br label %.outer

.outer:                                           ; preds = %46, %3
  %.016.ph = phi i32 [ %33, %46 ], [ %7, %3 ]
  %.0.ph = phi i32 [ %24, %46 ], [ %6, %3 ]
  br label %17

17:                                               ; preds = %17, %.outer
  %.0 = phi i32 [ %24, %17 ], [ %.0.ph, %.outer ]
  %18 = sext i32 %.0 to i64
  %19 = add nsw i64 %18, -1
  %20 = mul i64 %19, %13
  %21 = getelementptr i8, ptr %11, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !3
  %23 = icmp slt i32 %22, %16
  %24 = add i32 %.0, 1
  br i1 %23, label %17, label %.preheader

.preheader:                                       ; preds = %17
  %25 = getelementptr i8, ptr %11, i64 %20
  br label %26

26:                                               ; preds = %26, %.preheader
  %.1 = phi i32 [ %33, %26 ], [ %.016.ph, %.preheader ]
  %27 = sext i32 %.1 to i64
  %28 = add nsw i64 %27, -1
  %29 = mul i64 %28, %13
  %30 = getelementptr i8, ptr %11, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !3
  %32 = icmp sgt i32 %31, %16
  %33 = add i32 %.1, -1
  br i1 %32, label %26, label %34

34:                                               ; preds = %26
  %.not = icmp slt i32 %.0, %.1
  br i1 %.not, label %46, label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %1, align 4, !tbaa !3
  %37 = add i32 %.0, -1
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  store i32 %37, ptr %5, align 4, !tbaa !3
  call void @_QFPq2sort(ptr nonnull %0, ptr nonnull %1, ptr nonnull %5)
  br label %40

40:                                               ; preds = %39, %35
  %41 = load i32, ptr %2, align 4, !tbaa !3
  %42 = add i32 %.1, 1
  %43 = icmp sgt i32 %41, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %40
  store i32 %42, ptr %4, align 4, !tbaa !3
  call void @_QFPq2sort(ptr nonnull %0, ptr nonnull %4, ptr nonnull %2)
  br label %45

45:                                               ; preds = %44, %40
  ret void

46:                                               ; preds = %34
  %47 = getelementptr i8, ptr %11, i64 %29
  store i32 %31, ptr %25, align 4, !tbaa !3
  store i32 %22, ptr %47, align 4, !tbaa !3
  br label %.outer
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #5

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #5

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { noreturn }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nofree nosync nounwind memory(readwrite, inaccessiblemem: none) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
