program main
  implicit none
  integer :: n, i
  real(8) :: res(50)
  read (*, *) n
  read (*, *) res(1:n)
  do i = 1, n - 1
    call insertion_sort(res(1:n))
    res(i + 1) = (res(i) + res(i + 1)) * 0.5
  end do
  write (*, "(f0.7)") res(n)

  contains

  subroutine insertion_sort(s)
    real(8), intent(inout) :: s(:)
    real(8) :: tmp
    integer :: i, j
    do i = 2, size(s)  ! ループ終了時に [1, i] が昇順
      do j = i, 2, -1  ! i の位置にあった新要素が適切な位置に来るまで隣同士 swap
        if (s(j) >= s(j - 1)) exit
        tmp = s(j)
        s(j) = s(j - 1)
        s(j - 1) = tmp
      end do
    end do
  end subroutine insertion_sort
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"

@_QFEres = internal global [50 x double] undef
@_QQcl.ebb86c783ff7fc913404ce4e0b276c97 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3456/source.f\00"
@_QQcl.2866302E3729 = linkonce constant [6 x i8] c"(f0.7)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ebb86c783ff7fc913404ce4e0b276c97, i32 5)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.ebb86c783ff7fc913404ce4e0b276c97, i32 6)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = call i32 @llvm.smax.i32(i32 %7, i32 0)
  %9 = zext i32 %8 to i64
  store ptr @_QFEres, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 8, 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 %1, 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 %1, 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 %1, i64 0, i32 4
  store i8 28, 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 %1, 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 %1, 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 %1, 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 %1, i64 0, i32 7, i64 0, i64 1
  store i64 %9, 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 %1, i64 0, i32 7, i64 0, i64 2
  store i64 8, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %10 = call i1 @_FortranAioInputDescriptor(ptr %6, ptr nonnull %1)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %6)
  %12 = load i32, ptr %2, align 4, !tbaa !3
  %13 = add i32 %12, -1
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %15 = zext i32 %13 to i64
  %16 = call i32 @llvm.smax.i32(i32 %12, i32 0)
  %17 = icmp ugt i32 %16, 1
  br i1 %17, label %.preheader.i.preheader.us, label %_QFPinsertion_sort.exit.lver.check

_QFPinsertion_sort.exit.lver.check:               ; preds = %.lr.ph
  %18 = add nsw i64 %15, -1
  %19 = trunc i64 %18 to i32
  %20 = icmp ugt i32 %19, 2147483645
  %21 = icmp ugt i64 %18, 4294967295
  %22 = or i1 %20, %21
  br i1 %22, label %_QFPinsertion_sort.exit.lver.orig.preheader, label %_QFPinsertion_sort.exit.ph

_QFPinsertion_sort.exit.lver.orig.preheader:      ; preds = %_QFPinsertion_sort.exit.lver.check
  %xtraiter34 = and i64 %15, 1
  %23 = icmp eq i64 %18, 0
  br i1 %23, label %._crit_edge.loopexit32.unr-lcssa, label %_QFPinsertion_sort.exit.lver.orig.preheader.new

_QFPinsertion_sort.exit.lver.orig.preheader.new:  ; preds = %_QFPinsertion_sort.exit.lver.orig.preheader
  %unroll_iter36 = and i64 %15, 4294967294
  br label %_QFPinsertion_sort.exit.lver.orig

_QFPinsertion_sort.exit.lver.orig:                ; preds = %_QFPinsertion_sort.exit.lver.orig, %_QFPinsertion_sort.exit.lver.orig.preheader.new
  %indvars.iv.lver.orig = phi i64 [ 1, %_QFPinsertion_sort.exit.lver.orig.preheader.new ], [ %indvars.iv.next.lver.orig.1, %_QFPinsertion_sort.exit.lver.orig ]
  %niter37 = phi i64 [ 0, %_QFPinsertion_sort.exit.lver.orig.preheader.new ], [ %niter37.next.1, %_QFPinsertion_sort.exit.lver.orig ]
  %24 = add nsw i64 %indvars.iv.lver.orig, -1
  %25 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !3
  %indvars.iv.next.lver.orig = shl i64 %indvars.iv.lver.orig, 32
  %sext.lver.orig = add i64 %indvars.iv.next.lver.orig, 4294967296
  %27 = ashr exact i64 %sext.lver.orig, 32
  %28 = add nsw i64 %27, -1
  %29 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !3
  %31 = fadd contract double %26, %30
  %32 = fmul contract double %31, 5.000000e-01
  store double %32, ptr %29, align 8, !tbaa !3
  %33 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %indvars.iv.lver.orig
  %34 = load double, ptr %33, align 8, !tbaa !3
  %indvars.iv.next.lver.orig.1 = add nuw nsw i64 %indvars.iv.lver.orig, 2
  %sext.lver.orig.1 = shl i64 %indvars.iv.next.lver.orig.1, 32
  %35 = ashr exact i64 %sext.lver.orig.1, 32
  %36 = add nsw i64 %35, -1
  %37 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !3
  %39 = fadd contract double %34, %38
  %40 = fmul contract double %39, 5.000000e-01
  store double %40, ptr %37, align 8, !tbaa !3
  %niter37.next.1 = add i64 %niter37, 2
  %niter37.ncmp.1 = icmp eq i64 %niter37.next.1, %unroll_iter36
  br i1 %niter37.ncmp.1, label %._crit_edge.loopexit32.unr-lcssa, label %_QFPinsertion_sort.exit.lver.orig

_QFPinsertion_sort.exit.ph:                       ; preds = %_QFPinsertion_sort.exit.lver.check
  %load_initial = load double, ptr @_QFEres, align 16
  %xtraiter = and i64 %15, 1
  %41 = icmp eq i64 %18, 0
  br i1 %41, label %._crit_edge.loopexit33.unr-lcssa, label %_QFPinsertion_sort.exit.ph.new

_QFPinsertion_sort.exit.ph.new:                   ; preds = %_QFPinsertion_sort.exit.ph
  %unroll_iter = and i64 %15, 4294967294
  br label %_QFPinsertion_sort.exit

.preheader.i.preheader.us:                        ; preds = %.lr.ph, %_QFPinsertion_sort.exit.loopexit.us
  %indvars.iv24 = phi i64 [ %indvars.iv.next25, %_QFPinsertion_sort.exit.loopexit.us ], [ 1, %.lr.ph ]
  br label %.preheader.i.us

.preheader.i.us:                                  ; preds = %.preheader.i.preheader.us, %._crit_edge.i.us
  %.01221.i.us = phi i32 [ %57, %._crit_edge.i.us ], [ 2, %.preheader.i.preheader.us ]
  %.016.i.us = add i32 %.01221.i.us, -1
  %42 = icmp sgt i32 %.016.i.us, 0
  br i1 %42, label %.lr.ph.i.us, label %._crit_edge.i.us

.lr.ph.i.us:                                      ; preds = %.preheader.i.us, %55
  %.018.i.us = phi i32 [ %.0.i.us, %55 ], [ %.016.i.us, %.preheader.i.us ]
  %.01117.i.us = phi i32 [ %48, %55 ], [ %.01221.i.us, %.preheader.i.us ]
  %43 = sext i32 %.01117.i.us to i64
  %44 = shl nsw i64 %43, 3
  %45 = add nsw i64 %44, -8
  %46 = getelementptr i8, ptr @_QFEres, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !3
  %48 = add i32 %.01117.i.us, -1
  %49 = sext i32 %48 to i64
  %50 = shl nsw i64 %49, 3
  %51 = add nsw i64 %50, -8
  %52 = getelementptr i8, ptr @_QFEres, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !3
  %54 = fcmp ult double %47, %53
  br i1 %54, label %55, label %._crit_edge.i.us

55:                                               ; preds = %.lr.ph.i.us
  store double %53, ptr %46, align 8, !tbaa !3
  store double %47, ptr %52, align 8, !tbaa !3
  %.0.i.us = add i32 %.018.i.us, -1
  %56 = icmp sgt i32 %.0.i.us, 0
  br i1 %56, label %.lr.ph.i.us, label %._crit_edge.i.us

._crit_edge.i.us:                                 ; preds = %.lr.ph.i.us, %55, %.preheader.i.us
  %57 = add nuw i32 %.01221.i.us, 1
  %exitcond.not.i.us = icmp eq i32 %.01221.i.us, %16
  br i1 %exitcond.not.i.us, label %_QFPinsertion_sort.exit.loopexit.us, label %.preheader.i.us

_QFPinsertion_sort.exit.loopexit.us:              ; preds = %._crit_edge.i.us
  %58 = add nsw i64 %indvars.iv24, -1
  %59 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !3
  %indvars.iv.next25 = add nuw nsw i64 %indvars.iv24, 1
  %sext28 = shl i64 %indvars.iv.next25, 32
  %61 = ashr exact i64 %sext28, 32
  %62 = add nsw i64 %61, -1
  %63 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !3
  %65 = fadd contract double %60, %64
  %66 = fmul contract double %65, 5.000000e-01
  store double %66, ptr %63, align 8, !tbaa !3
  %exitcond27.not = icmp eq i64 %indvars.iv24, %15
  br i1 %exitcond27.not, label %._crit_edge, label %.preheader.i.preheader.us

_QFPinsertion_sort.exit:                          ; preds = %_QFPinsertion_sort.exit, %_QFPinsertion_sort.exit.ph.new
  %store_forwarded = phi double [ %load_initial, %_QFPinsertion_sort.exit.ph.new ], [ %78, %_QFPinsertion_sort.exit ]
  %indvars.iv = phi i64 [ 1, %_QFPinsertion_sort.exit.ph.new ], [ %indvars.iv.next.1, %_QFPinsertion_sort.exit ]
  %niter = phi i64 [ 0, %_QFPinsertion_sort.exit.ph.new ], [ %niter.next.1, %_QFPinsertion_sort.exit ]
  %indvars.iv.next = shl i64 %indvars.iv, 32
  %sext = add i64 %indvars.iv.next, 4294967296
  %67 = ashr exact i64 %sext, 32
  %68 = add nsw i64 %67, -1
  %69 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !3
  %71 = fadd contract double %store_forwarded, %70
  %72 = fmul contract double %71, 5.000000e-01
  store double %72, ptr %69, align 8, !tbaa !3
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %sext.1 = shl i64 %indvars.iv.next.1, 32
  %73 = ashr exact i64 %sext.1, 32
  %74 = add nsw i64 %73, -1
  %75 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %74
  %76 = load double, ptr %75, align 8, !tbaa !3
  %77 = fadd contract double %72, %76
  %78 = fmul contract double %77, 5.000000e-01
  store double %78, ptr %75, align 8, !tbaa !3
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit33.unr-lcssa.loopexit, label %_QFPinsertion_sort.exit

._crit_edge.loopexit32.unr-lcssa:                 ; preds = %_QFPinsertion_sort.exit.lver.orig, %_QFPinsertion_sort.exit.lver.orig.preheader
  %indvars.iv.lver.orig.unr = phi i64 [ 1, %_QFPinsertion_sort.exit.lver.orig.preheader ], [ %indvars.iv.next.lver.orig.1, %_QFPinsertion_sort.exit.lver.orig ]
  %lcmp.mod35.not = icmp eq i64 %xtraiter34, 0
  br i1 %lcmp.mod35.not, label %._crit_edge, label %_QFPinsertion_sort.exit.lver.orig.epil

_QFPinsertion_sort.exit.lver.orig.epil:           ; preds = %._crit_edge.loopexit32.unr-lcssa
  %79 = add nsw i64 %indvars.iv.lver.orig.unr, -1
  %80 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !3
  %indvars.iv.next.lver.orig.epil = shl i64 %indvars.iv.lver.orig.unr, 32
  %sext.lver.orig.epil = add i64 %indvars.iv.next.lver.orig.epil, 4294967296
  %82 = ashr exact i64 %sext.lver.orig.epil, 32
  %83 = add nsw i64 %82, -1
  %84 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %83
  %85 = load double, ptr %84, align 8, !tbaa !3
  %86 = fadd contract double %81, %85
  %87 = fmul contract double %86, 5.000000e-01
  store double %87, ptr %84, align 8, !tbaa !3
  br label %._crit_edge

._crit_edge.loopexit33.unr-lcssa.loopexit:        ; preds = %_QFPinsertion_sort.exit
  %88 = shl i64 %indvars.iv, 32
  %89 = add i64 %88, 12884901888
  %90 = ashr exact i64 %89, 32
  %91 = add nsw i64 %90, -1
  br label %._crit_edge.loopexit33.unr-lcssa

._crit_edge.loopexit33.unr-lcssa:                 ; preds = %._crit_edge.loopexit33.unr-lcssa.loopexit, %_QFPinsertion_sort.exit.ph
  %store_forwarded.unr = phi double [ %load_initial, %_QFPinsertion_sort.exit.ph ], [ %78, %._crit_edge.loopexit33.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i64 [ 1, %_QFPinsertion_sort.exit.ph ], [ %91, %._crit_edge.loopexit33.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %_QFPinsertion_sort.exit.epil

_QFPinsertion_sort.exit.epil:                     ; preds = %._crit_edge.loopexit33.unr-lcssa
  %92 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %indvars.iv.unr
  %93 = load double, ptr %92, align 8, !tbaa !3
  %94 = fadd contract double %store_forwarded.unr, %93
  %95 = fmul contract double %94, 5.000000e-01
  store double %95, ptr %92, align 8, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %_QFPinsertion_sort.exit.epil, %._crit_edge.loopexit33.unr-lcssa, %_QFPinsertion_sort.exit.lver.orig.epil, %._crit_edge.loopexit32.unr-lcssa, %_QFPinsertion_sort.exit.loopexit.us, %0
  %96 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.2866302E3729, i64 6, ptr null, i32 -1, ptr nonnull @_QQcl.ebb86c783ff7fc913404ce4e0b276c97, i32 11)
  %97 = load i32, ptr %2, align 4, !tbaa !3
  %98 = sext i32 %97 to i64
  %99 = add nsw i64 %98, -1
  %100 = getelementptr [50 x double], ptr @_QFEres, i64 0, i64 %99
  %101 = load double, ptr %100, align 8, !tbaa !3
  %102 = call i1 @_FortranAioOutputReal64(ptr %96, double %101)
  %103 = call i32 @_FortranAioEndIoStatement(ptr %96)
  ret void
}

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none)
define void @_QFPinsertion_sort(ptr nocapture readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 1
  %3 = load i64, ptr %2, align 8, !tbaa !7
  %4 = trunc i64 %3 to i32
  %.01320 = add i32 %4, -1
  %5 = icmp sgt i32 %.01320, 0
  br i1 %5, label %.preheader.lr.ph, label %._crit_edge23

.preheader.lr.ph:                                 ; preds = %1
  %6 = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %0, i64 0, i32 7, i64 0, i64 2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.01221 = phi i32 [ 2, %.preheader.lr.ph ], [ %25, %._crit_edge ]
  %.016 = add i32 %.01221, -1
  %7 = icmp sgt i32 %.016, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %8 = load ptr, ptr %0, align 8, !tbaa !7
  %9 = load i64, ptr %6, align 8, !tbaa !7
  br label %10

10:                                               ; preds = %.lr.ph, %23
  %.018 = phi i32 [ %.016, %.lr.ph ], [ %.0, %23 ]
  %.01117 = phi i32 [ %.01221, %.lr.ph ], [ %16, %23 ]
  %11 = sext i32 %.01117 to i64
  %12 = add nsw i64 %11, -1
  %13 = mul i64 %9, %12
  %14 = getelementptr i8, ptr %8, i64 %13
  %15 = load double, ptr %14, align 8, !tbaa !3
  %16 = add i32 %.01117, -1
  %17 = sext i32 %16 to i64
  %18 = add nsw i64 %17, -1
  %19 = mul i64 %9, %18
  %20 = getelementptr i8, ptr %8, i64 %19
  %21 = load double, ptr %20, align 8, !tbaa !3
  %22 = fcmp ult double %15, %21
  br i1 %22, label %23, label %._crit_edge

23:                                               ; preds = %10
  store double %21, ptr %14, align 8, !tbaa !3
  store double %15, ptr %20, align 8, !tbaa !3
  %.0 = add i32 %.018, -1
  %24 = icmp sgt i32 %.0, 0
  br i1 %24, label %10, label %._crit_edge

._crit_edge:                                      ; preds = %23, %10, %.preheader
  %25 = add nuw i32 %.01221, 1
  %exitcond.not = icmp eq i32 %.01221, %4
  br i1 %exitcond.not, label %._crit_edge23, label %.preheader

._crit_edge23:                                    ; preds = %._crit_edge, %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 @_FortranAioOutputReal64(ptr, double) local_unnamed_addr

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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) }
attributes #1 = { 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}
