integer :: n,w(100),i,ans
ans = 10**7

read*,n
read*,w(1:n)

do i = 1,n-1
  ans = min( ans, abs(sum(w(1:i))-sum(w(i+1:n))) )
end do

print*,ans
end

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

@_QFEw = internal global [100 x i32] undef
@_QQcl.96d5d2c835a500664b426690bcfa4377 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_4084/source.f\00"
@_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.96d5d2c835a500664b426690bcfa4377, i32 4)
  %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.96d5d2c835a500664b426690bcfa4377, i32 5)
  %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 @_QFEw, 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 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 %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 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 %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 4, 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 = sext i32 %12 to i64
  br label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %_FortranASumInteger4x1_contract_simplified.exit49, %.lr.ph
  %indvar = phi i32 [ %indvar.next, %_FortranASumInteger4x1_contract_simplified.exit49 ], [ 0, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %_FortranASumInteger4x1_contract_simplified.exit49 ], [ 1, %.lr.ph ]
  %.062 = phi i32 [ %61, %_FortranASumInteger4x1_contract_simplified.exit49 ], [ 10000000, %.lr.ph ]
  %17 = add i32 %indvar, 1
  %smax72 = call i32 @llvm.smax.i32(i32 %17, i32 0)
  %18 = zext i32 %smax72 to i64
  %19 = add i32 %indvar, 2
  %20 = sext i32 %19 to i64
  %21 = sub nsw i64 %16, %20
  %smax = call i64 @llvm.smax.i64(i64 %21, i64 -1)
  %22 = add nsw i64 %smax, 1
  %23 = trunc i64 %indvars.iv to i32
  %24 = call i32 @llvm.smax.i32(i32 %23, i32 0)
  %25 = zext i32 %24 to i64
  %min.iters.check75 = icmp ult i32 %smax72, 8
  br i1 %min.iters.check75, label %.lr.ph.i.preheader92, label %vector.ph76

vector.ph76:                                      ; preds = %.lr.ph.i.preheader
  %n.vec78 = and i64 %18, 2147483640
  br label %vector.body81

vector.body81:                                    ; preds = %vector.body81, %vector.ph76
  %index82 = phi i64 [ 0, %vector.ph76 ], [ %index.next87, %vector.body81 ]
  %vec.phi83 = phi <4 x i32> [ zeroinitializer, %vector.ph76 ], [ %29, %vector.body81 ]
  %vec.phi84 = phi <4 x i32> [ zeroinitializer, %vector.ph76 ], [ %30, %vector.body81 ]
  %26 = shl i64 %index82, 2
  %27 = getelementptr i8, ptr @_QFEw, i64 %26
  %wide.load85 = load <4 x i32>, ptr %27, align 16, !tbaa !3
  %28 = getelementptr i32, ptr %27, i64 4
  %wide.load86 = load <4 x i32>, ptr %28, align 16, !tbaa !3
  %29 = add <4 x i32> %wide.load85, %vec.phi83
  %30 = add <4 x i32> %wide.load86, %vec.phi84
  %index.next87 = add nuw i64 %index82, 8
  %31 = icmp eq i64 %index.next87, %n.vec78
  br i1 %31, label %middle.block73, label %vector.body81, !llvm.loop !9

middle.block73:                                   ; preds = %vector.body81
  %bin.rdx88 = add <4 x i32> %30, %29
  %32 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx88)
  %cmp.n80 = icmp eq i64 %n.vec78, %18
  br i1 %cmp.n80, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i.preheader92

.lr.ph.i.preheader92:                             ; preds = %.lr.ph.i.preheader, %middle.block73
  %.ph93 = phi i32 [ 0, %.lr.ph.i.preheader ], [ %32, %middle.block73 ]
  %.ph94 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec78, %middle.block73 ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader92, %.lr.ph.i
  %33 = phi i32 [ %38, %.lr.ph.i ], [ %.ph93, %.lr.ph.i.preheader92 ]
  %34 = phi i64 [ %39, %.lr.ph.i ], [ %.ph94, %.lr.ph.i.preheader92 ]
  %35 = shl i64 %34, 2
  %36 = getelementptr i8, ptr @_QFEw, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !3
  %38 = add i32 %37, %33
  %39 = add nuw nsw i64 %34, 1
  %exitcond.not.i = icmp eq i64 %39, %25
  br i1 %exitcond.not.i, label %_FortranASumInteger4x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !12

_FortranASumInteger4x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block73
  %.lcssa = phi i32 [ %32, %middle.block73 ], [ %38, %.lr.ph.i ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %40 = ashr exact i64 %sext, 32
  %41 = add nsw i64 %40, -1
  %42 = sub nsw i64 %16, %40
  %43 = call i64 @llvm.smax.i64(i64 %42, i64 -1)
  %44 = getelementptr [100 x i32], ptr @_QFEw, i64 0, i64 %41
  %.not60 = icmp slt i64 %42, 0
  br i1 %.not60, label %_FortranASumInteger4x1_contract_simplified.exit49, label %.lr.ph.i46.preheader

.lr.ph.i46.preheader:                             ; preds = %_FortranASumInteger4x1_contract_simplified.exit
  %min.iters.check = icmp ult i64 %22, 8
  br i1 %min.iters.check, label %.lr.ph.i46.preheader90, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.i46.preheader
  %n.vec = and i64 %22, -8
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %48, %vector.body ]
  %vec.phi70 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %49, %vector.body ]
  %45 = shl i64 %index, 2
  %46 = getelementptr i8, ptr %44, i64 %45
  %wide.load = load <4 x i32>, ptr %46, align 4, !tbaa !3
  %47 = getelementptr i32, ptr %46, i64 4
  %wide.load71 = load <4 x i32>, ptr %47, align 4, !tbaa !3
  %48 = add <4 x i32> %wide.load, %vec.phi
  %49 = add <4 x i32> %wide.load71, %vec.phi70
  %index.next = add nuw i64 %index, 8
  %50 = icmp eq i64 %index.next, %n.vec
  br i1 %50, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %49, %48
  %51 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %22, %n.vec
  br i1 %cmp.n, label %_FortranASumInteger4x1_contract_simplified.exit49, label %.lr.ph.i46.preheader90

.lr.ph.i46.preheader90:                           ; preds = %.lr.ph.i46.preheader, %middle.block
  %.ph = phi i32 [ 0, %.lr.ph.i46.preheader ], [ %51, %middle.block ]
  %.ph91 = phi i64 [ 0, %.lr.ph.i46.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph.i46

.lr.ph.i46:                                       ; preds = %.lr.ph.i46.preheader90, %.lr.ph.i46
  %52 = phi i32 [ %57, %.lr.ph.i46 ], [ %.ph, %.lr.ph.i46.preheader90 ]
  %53 = phi i64 [ %58, %.lr.ph.i46 ], [ %.ph91, %.lr.ph.i46.preheader90 ]
  %54 = shl i64 %53, 2
  %55 = getelementptr i8, ptr %44, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !3
  %57 = add i32 %56, %52
  %58 = add nuw nsw i64 %53, 1
  %exitcond.not.i47 = icmp eq i64 %53, %43
  br i1 %exitcond.not.i47, label %_FortranASumInteger4x1_contract_simplified.exit49, label %.lr.ph.i46, !llvm.loop !14

_FortranASumInteger4x1_contract_simplified.exit49: ; preds = %.lr.ph.i46, %middle.block, %_FortranASumInteger4x1_contract_simplified.exit
  %.lcssa.i48 = phi i32 [ 0, %_FortranASumInteger4x1_contract_simplified.exit ], [ %51, %middle.block ], [ %57, %.lr.ph.i46 ]
  %59 = sub i32 %.lcssa, %.lcssa.i48
  %60 = call i32 @llvm.abs.i32(i32 %59, i1 false)
  %61 = call i32 @llvm.smin.i32(i32 %.062, i32 %60)
  %exitcond.not = icmp eq i64 %indvars.iv, %15
  %indvar.next = add i32 %indvar, 1
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.i.preheader

._crit_edge:                                      ; preds = %_FortranASumInteger4x1_contract_simplified.exit49, %0
  %.0.lcssa = phi i32 [ 10000000, %0 ], [ %61, %_FortranASumInteger4x1_contract_simplified.exit49 ]
  %62 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.96d5d2c835a500664b426690bcfa4377, i32 11)
  %63 = call i1 @_FortranAioOutputInteger32(ptr %62, i32 %.0.lcssa)
  %64 = call i32 @_FortranAioEndIoStatement(ptr %62)
  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 @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #0

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #1

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind 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}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
