program Spp
    implicit none
    integer(16),allocatable :: a(:)
    integer :: n, i
    integer(16) :: ans = 0, t = 0
    read *, n
    allocate(a(n))
    read *, a(1:n)
    t = sum(a(1:n))
    do i = 1, n-1
        t  = t - a(i)
        ans = ans + t * a(i)
    end do
    ans = mod(ans, 1000000007)
    print *, ans
end program
; 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
@_QFEans = internal unnamed_addr global i128 0
@_QQcl.5ccc139337cc911bfe72a8245257a2f8 = linkonce constant [72 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_704/source.f\00"
@_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 i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.5ccc139337cc911bfe72a8245257a2f8, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %5 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %6 = load i32, ptr %2, align 4, !tbaa !3
  %7 = call i32 @llvm.smax.i32(i32 %6, i32 0)
  %8 = zext i32 %7 to i64
  %9 = shl nuw nsw i64 %8, 4
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEa.0, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.5ccc139337cc911bfe72a8245257a2f8, i32 8)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %12 = load i32, ptr %2, align 4, !tbaa !3
  %13 = call i32 @llvm.smax.i32(i32 %12, i32 0)
  %14 = zext i32 %13 to i64
  store ptr %.unpack, 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 16, 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 11, 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 %14, 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 16, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %15 = call i1 @_FortranAioInputDescriptor(ptr %11, ptr nonnull %1)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %.unpack170 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %17 = load i32, ptr %2, align 4, !tbaa !3
  %18 = call i32 @llvm.smax.i32(i32 %17, i32 0)
  %19 = zext i32 %18 to i64
  %.not = icmp slt i32 %17, 1
  br i1 %.not, label %_FortranASumInteger16x1_contract_simplified.exit, label %.lr.ph.i.preheader

.lr.ph.i.preheader:                               ; preds = %0
  %20 = add nsw i64 %19, -1
  %xtraiter = and i64 %19, 3
  %21 = icmp ult i64 %20, 3
  br i1 %21, label %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa, label %.lr.ph.i.preheader.new

.lr.ph.i.preheader.new:                           ; preds = %.lr.ph.i.preheader
  %unroll_iter = and i64 %19, 2147483644
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i, %.lr.ph.i.preheader.new
  %22 = phi i128 [ 0, %.lr.ph.i.preheader.new ], [ %42, %.lr.ph.i ]
  %23 = phi i64 [ 0, %.lr.ph.i.preheader.new ], [ %43, %.lr.ph.i ]
  %niter = phi i64 [ 0, %.lr.ph.i.preheader.new ], [ %niter.next.3, %.lr.ph.i ]
  %24 = shl i64 %23, 4
  %25 = getelementptr i8, ptr %.unpack170, i64 %24
  %26 = load i128, ptr %25, align 8, !tbaa !3
  %27 = add i128 %26, %22
  %28 = shl i64 %23, 4
  %29 = or i64 %28, 16
  %30 = getelementptr i8, ptr %.unpack170, i64 %29
  %31 = load i128, ptr %30, align 8, !tbaa !3
  %32 = add i128 %31, %27
  %33 = shl i64 %23, 4
  %34 = or i64 %33, 32
  %35 = getelementptr i8, ptr %.unpack170, i64 %34
  %36 = load i128, ptr %35, align 8, !tbaa !3
  %37 = add i128 %36, %32
  %38 = shl i64 %23, 4
  %39 = or i64 %38, 48
  %40 = getelementptr i8, ptr %.unpack170, i64 %39
  %41 = load i128, ptr %40, align 8, !tbaa !3
  %42 = add i128 %41, %37
  %43 = add nuw nsw i64 %23, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa, label %.lr.ph.i

_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa: ; preds = %.lr.ph.i, %.lr.ph.i.preheader
  %.lcssa214.ph = phi i128 [ undef, %.lr.ph.i.preheader ], [ %42, %.lr.ph.i ]
  %.unr = phi i128 [ 0, %.lr.ph.i.preheader ], [ %42, %.lr.ph.i ]
  %.unr215 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %43, %.lr.ph.i ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %_FortranASumInteger16x1_contract_simplified.exit, label %.lr.ph.i.epil

.lr.ph.i.epil:                                    ; preds = %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa, %.lr.ph.i.epil
  %44 = phi i128 [ %49, %.lr.ph.i.epil ], [ %.unr, %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa ]
  %45 = phi i64 [ %50, %.lr.ph.i.epil ], [ %.unr215, %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.i.epil ], [ 0, %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa ]
  %46 = shl i64 %45, 4
  %47 = getelementptr i8, ptr %.unpack170, i64 %46
  %48 = load i128, ptr %47, align 8, !tbaa !3
  %49 = add i128 %48, %44
  %50 = add nuw nsw i64 %45, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %_FortranASumInteger16x1_contract_simplified.exit, label %.lr.ph.i.epil, !llvm.loop !9

_FortranASumInteger16x1_contract_simplified.exit: ; preds = %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa, %.lr.ph.i.epil, %0
  %.lcssa.i = phi i128 [ 0, %0 ], [ %.lcssa214.ph, %_FortranASumInteger16x1_contract_simplified.exit.loopexit.unr-lcssa ], [ %49, %.lr.ph.i.epil ]
  %51 = add i32 %17, -1
  %_QFEans.promoted = load i128, ptr @_QFEans, align 8, !tbaa !3
  %52 = icmp sgt i32 %51, 0
  br i1 %52, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %_FortranASumInteger16x1_contract_simplified.exit
  %53 = zext i32 %51 to i64
  %xtraiter217 = and i64 %53, 1
  %54 = icmp eq i32 %51, 1
  br i1 %54, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter223 = and i64 %53, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %.lr.ph ]
  %55 = phi i128 [ %.lcssa.i, %.lr.ph.preheader.new ], [ %65, %.lr.ph ]
  %56 = phi i128 [ %_QFEans.promoted, %.lr.ph.preheader.new ], [ %67, %.lr.ph ]
  %niter224 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter224.next.1, %.lr.ph ]
  %57 = add nsw i64 %indvars.iv, -1
  %58 = getelementptr i128, ptr %.unpack170, i64 %57
  %59 = load i128, ptr %58, align 8, !tbaa !3
  %60 = sub i128 %55, %59
  %61 = mul i128 %60, %59
  %62 = add i128 %56, %61
  %63 = getelementptr i128, ptr %.unpack170, i64 %indvars.iv
  %64 = load i128, ptr %63, align 8, !tbaa !3
  %65 = sub i128 %60, %64
  %66 = mul i128 %65, %64
  %67 = add i128 %62, %66
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter224.next.1 = add i64 %niter224, 2
  %niter224.ncmp.1 = icmp eq i64 %niter224.next.1, %unroll_iter223
  br i1 %niter224.ncmp.1, label %._crit_edge.loopexit.unr-lcssa.loopexit, label %.lr.ph

._crit_edge.loopexit.unr-lcssa.loopexit:          ; preds = %.lr.ph
  %68 = add nuw nsw i64 %indvars.iv, 1
  br label %._crit_edge.loopexit.unr-lcssa

._crit_edge.loopexit.unr-lcssa:                   ; preds = %._crit_edge.loopexit.unr-lcssa.loopexit, %.lr.ph.preheader
  %.lcssa.ph = phi i128 [ undef, %.lr.ph.preheader ], [ %67, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %68, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.unr219 = phi i128 [ %.lcssa.i, %.lr.ph.preheader ], [ %65, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %.unr220 = phi i128 [ %_QFEans.promoted, %.lr.ph.preheader ], [ %67, %._crit_edge.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod221.not = icmp eq i64 %xtraiter217, 0
  br i1 %lcmp.mod221.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %69 = getelementptr i128, ptr %.unpack170, i64 %indvars.iv.unr
  %70 = load i128, ptr %69, align 8, !tbaa !3
  %71 = sub i128 %.unr219, %70
  %72 = mul i128 %71, %70
  %73 = add i128 %.unr220, %72
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %_FortranASumInteger16x1_contract_simplified.exit
  %74 = phi i128 [ %_QFEans.promoted, %_FortranASumInteger16x1_contract_simplified.exit ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %73, %.lr.ph.epil ]
  %75 = srem i128 %74, 1000000007
  store i128 %75, ptr @_QFEans, align 8, !tbaa !3
  %76 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.5ccc139337cc911bfe72a8245257a2f8, i32 15)
  %77 = load i128, ptr @_QFEans, align 8, !tbaa !3
  %78 = call i1 @_FortranAioOutputInteger128(ptr %76, i128 %77)
  %79 = call i32 @_FortranAioEndIoStatement(ptr %76)
  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 @_FortranAioOutputInteger128(ptr, i128) local_unnamed_addr

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
