program main
  implicit none
  integer :: n
  integer, allocatable :: d(:)
  read (*, *) n
  allocate (d(n))
  read (*, *) d
  call quicksort(d)
  write (*, "(i0)") d(n / 2 + 1) - d(n / 2)
  contains
  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main

; 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"

@_QFEd.0 = internal unnamed_addr global ptr null
@_QFEd.8 = internal unnamed_addr global i64 0
@_QQcl.e0e926731d622d71b598a8927787ae40 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3877/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca i32, align 4
  %4 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e0e926731d622d71b598a8927787ae40, i32 5)
  %5 = call i1 @_FortranAioInputInteger(ptr %4, ptr nonnull %3, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %4)
  %7 = load i32, ptr %3, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  %10 = shl nuw nsw i64 %9, 2
  %11 = call ptr @malloc(i64 %10)
  store ptr %11, ptr @_QFEd.0, align 8, !tbaa !7
  store i64 %9, ptr @_QFEd.8, align 8, !tbaa !7
  %12 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e0e926731d622d71b598a8927787ae40, i32 7)
  %.unpack = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %.unpack133.unpack.unpack135 = load i64, ptr @_QFEd.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, 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 %2, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack133.unpack.unpack135, 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 %2, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %13 = call i1 @_FortranAioInputDescriptor(ptr %12, ptr nonnull %2)
  %14 = call i32 @_FortranAioEndIoStatement(ptr %12)
  %.unpack138 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %.unpack145.unpack.unpack147 = load i64, ptr @_QFEd.8, align 8, !tbaa !7
  store ptr %.unpack138, ptr %1, align 8, !tbaa !7
  %.fca.1.gep71 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep71, align 8, !tbaa !7
  %.fca.2.gep73 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep73, align 8, !tbaa !7
  %.fca.3.gep75 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep75, align 4, !tbaa !7
  %.fca.4.gep77 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep77, align 1, !tbaa !7
  %.fca.5.gep79 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep79, align 2, !tbaa !7
  %.fca.6.gep81 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep81, align 1, !tbaa !7
  %.fca.7.0.0.gep83 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep83, align 8, !tbaa !7
  %.fca.7.0.1.gep85 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack145.unpack.unpack147, ptr %.fca.7.0.1.gep85, align 8, !tbaa !7
  %.fca.7.0.2.gep87 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep87, align 8, !tbaa !7
  call void @_QFPquicksort(ptr nonnull %1)
  %15 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.e0e926731d622d71b598a8927787ae40, i32 9)
  %.unpack150 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %16 = load i32, ptr %3, align 4, !tbaa !3
  %17 = sdiv i32 %16, 2
  %18 = sext i32 %17 to i64
  %19 = getelementptr i32, ptr %.unpack150, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !3
  %narrow = add nsw i32 %17, -1
  %21 = sext i32 %narrow to i64
  %22 = getelementptr i32, ptr %.unpack150, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !3
  %24 = sub i32 %20, %23
  %25 = call i1 @_FortranAioOutputInteger32(ptr %15, i32 %24)
  %26 = call i32 @_FortranAioEndIoStatement(ptr %15)
  ret void
}

define void @_QFPquicksort(ptr nocapture readonly %0) local_unnamed_addr {
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %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 }, align 8
  %5 = alloca float, align 4
  %6 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 1
  %7 = load i64, ptr %6, align 8, !tbaa !7
  %8 = trunc i64 %7 to i32
  %9 = icmp slt i32 %8, 2
  br i1 %9, label %63, label %10

10:                                               ; preds = %1
  store ptr %5, ptr %4, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, 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 }, 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 }, ptr %4, i64 0, i32 3
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %4, i64 0, i32 4
  store i8 27, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, 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 }, ptr %4, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %11 = call {} @_FortranARandomNumber(ptr nonnull %4, ptr nonnull @_QQcl.e0e926731d622d71b598a8927787ae40, i32 19)
  %12 = load float, ptr %5, align 4, !tbaa !3
  %13 = sitofp i32 %8 to float
  %14 = fmul contract float %12, %13
  %15 = call contract float @llvm.floor.f32(float %14)
  %16 = fptosi float %15 to i32
  %17 = add i32 %16, 1
  %18 = call i32 @llvm.smin.i32(i32 %17, i32 %8)
  %19 = call i32 @llvm.smax.i32(i32 %18, i32 1)
  %20 = zext i32 %19 to i64
  %21 = add nsw i64 %20, -1
  %22 = load ptr, ptr %0, align 8, !tbaa !7
  %23 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 2
  %24 = load i64, ptr %23, align 8, !tbaa !7
  %25 = mul i64 %21, %24
  %26 = getelementptr i8, ptr %22, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !3
  br label %.outer

.outer:                                           ; preds = %61, %10
  %.058.ph = phi i32 [ %44, %61 ], [ %8, %10 ]
  %.0.ph = phi i32 [ %35, %61 ], [ 1, %10 ]
  br label %28

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

.preheader:                                       ; preds = %28
  %36 = getelementptr i8, ptr %22, i64 %31
  br label %37

37:                                               ; preds = %37, %.preheader
  %.1 = phi i32 [ %44, %37 ], [ %.058.ph, %.preheader ]
  %38 = sext i32 %.1 to i64
  %39 = add nsw i64 %38, -1
  %40 = mul i64 %39, %24
  %41 = getelementptr i8, ptr %22, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !3
  %43 = icmp sgt i32 %42, %27
  %44 = add i32 %.1, -1
  br i1 %43, label %37, label %45

45:                                               ; preds = %37
  %.not = icmp slt i32 %.0, %.1
  br i1 %.not, label %61, label %46

46:                                               ; preds = %45
  %47 = add i32 %.0, -1
  %48 = call i32 @llvm.smax.i32(i32 %47, i32 0)
  %49 = zext i32 %48 to i64
  store ptr %22, ptr %3, align 8, !tbaa !7
  %.fca.1.gep27 = 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.gep27, align 8, !tbaa !7
  %.fca.2.gep29 = 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.gep29, align 8, !tbaa !7
  %.fca.3.gep31 = 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.gep31, align 4, !tbaa !7
  %.fca.4.gep33 = 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.gep33, align 1, !tbaa !7
  %.fca.5.gep35 = 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.gep35, align 2, !tbaa !7
  %.fca.6.gep37 = 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.gep37, align 1, !tbaa !7
  %.fca.7.0.0.gep = 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.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 %3, i64 0, i32 7, i64 0, i64 1
  store i64 %49, 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 %3, i64 0, i32 7, i64 0, i64 2
  store i64 %24, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  call void @_QFPquicksort(ptr nonnull %3)
  %50 = add i32 %.1, 1
  %51 = sext i32 %50 to i64
  %52 = and i64 %7, 4294967295
  %53 = load i64, ptr %23, align 8, !tbaa !7
  %54 = load ptr, ptr %0, align 8, !tbaa !7
  %55 = add nsw i64 %51, -1
  %56 = mul i64 %53, %55
  %57 = getelementptr i8, ptr %54, i64 %56
  %58 = sub nsw i64 %52, %51
  %59 = call i64 @llvm.smax.i64(i64 %58, i64 -1)
  %60 = add nsw i64 %59, 1
  store ptr %57, ptr %2, align 8, !tbaa !7
  %.fca.1.gep41 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep41, align 8, !tbaa !7
  %.fca.2.gep43 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep43, align 8, !tbaa !7
  %.fca.3.gep45 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep45, align 4, !tbaa !7
  %.fca.4.gep47 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep47, align 1, !tbaa !7
  %.fca.5.gep49 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep49, align 2, !tbaa !7
  %.fca.6.gep51 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep51, align 1, !tbaa !7
  %.fca.7.0.0.gep53 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep53, align 8, !tbaa !7
  %.fca.7.0.1.gep55 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 1
  store i64 %60, ptr %.fca.7.0.1.gep55, align 8, !tbaa !7
  %.fca.7.0.2.gep57 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 2
  store i64 %53, ptr %.fca.7.0.2.gep57, align 8, !tbaa !7
  call void @_QFPquicksort(ptr nonnull %2)
  br label %63

61:                                               ; preds = %45
  %62 = getelementptr i8, ptr %22, i64 %40
  store i32 %42, ptr %36, align 4, !tbaa !3
  store i32 %33, ptr %62, align 4, !tbaa !3
  br label %.outer

63:                                               ; preds = %46, %1
  ret void
}

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 @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranARandomNumber(ptr, ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #1

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

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

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

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

!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}
