#import <stdio.h>
#import <stdlib.h>
#if !defined(MIN)
#define MIN(A,B)    ((A) < (B) ? (A) : (B))
#endif

#if !defined(MAX)
#define MAX(A,B)    ((A) > (B) ? (A) : (B))
#endif

int gcd(int a, int b){
    int M = MAX(a, b);
    int m = MIN(a, b);
    
    if (m == 0) {
        return M;
    }
    int r = M % m;
    if (r==0) return m;
    else return gcd(r,m);
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        int N;
        scanf("%d", &N);
        int *numbers = (int*)malloc(N * sizeof(int));
        
        int n;
        int i = 0;
        while (scanf("%d", &n) != EOF) {
            numbers[i] = n;
            i++;
        }
        
        int g = numbers[0];
        for(int i=1;i<N;i++){
            g=gcd(numbers[i],g);
        }
        printf("%d\n",g);

        free(numbers);
    }
    return 0;
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_368/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_368/source.m"
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"

$.objc_sel_namealloc = comdat any

$.objc_sel_namedrain = comdat any

$.objc_sel_nameinit = comdat any

@0 = private unnamed_addr constant [18 x i8] c"NSAutoreleasePool\00", align 1
@__objc_class_name_NSAutoreleasePool = external global i64
@__objc_class_ref_NSAutoreleasePool = weak local_unnamed_addr constant ptr @__objc_class_name_NSAutoreleasePool
@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
@1 = private unnamed_addr constant [12 x i8] c"AnotherHack\00", align 1
@2 = private unnamed_addr constant [33 x i8] c"__ObjC_Protocol_Holder_Ugly_Hack\00", align 1
@.objc_protocol_list = internal global { ptr, i64, [0 x ptr] } zeroinitializer, align 8
@3 = internal global { ptr, ptr, ptr, ptr, ptr } { ptr @1, ptr @2, ptr null, ptr null, ptr @.objc_protocol_list }, align 8
@.objc_sel_namealloc = linkonce_odr constant [6 x i8] c"alloc\00", comdat
@.objc_sel_namedrain = linkonce_odr constant [6 x i8] c"drain\00", comdat
@.objc_sel_nameinit = linkonce_odr constant [5 x i8] c"init\00", comdat
@.objc_selector_list = internal global [4 x { ptr, ptr }] [{ ptr, ptr } { ptr @.objc_sel_namealloc, ptr null }, { ptr, ptr } { ptr @.objc_sel_namedrain, ptr null }, { ptr, ptr } { ptr @.objc_sel_nameinit, ptr null }, { ptr, ptr } zeroinitializer], align 8
@4 = internal global { i64, ptr, i16, i16, [3 x ptr] } { i64 3, ptr @.objc_selector_list, i16 0, i16 1, [3 x ptr] [ptr @3, ptr null, ptr null] }, align 8
@.objc_source_file_name = private unnamed_addr constant [129 x i8] c"/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_368//data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_368/source.m\00", align 1
@5 = internal global { i64, i64, ptr, ptr } { i64 8, i64 32, ptr @.objc_source_file_name, ptr @4 }, align 8
@llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @.objc_load_function, ptr null }]

; Function Attrs: nofree nosync nounwind memory(none) uwtable
define dso_local i32 @gcd(i32 noundef %a, i32 noundef %b) local_unnamed_addr #0 {
entry:
  br label %tailrecurse

tailrecurse:                                      ; preds = %if.end, %entry
  %a.tr = phi i32 [ %a, %entry ], [ %rem, %if.end ]
  %b.tr = phi i32 [ %b, %entry ], [ %cond5, %if.end ]
  %cond = tail call i32 @llvm.smax.i32(i32 %a.tr, i32 %b.tr)
  %cond5 = tail call i32 @llvm.smin.i32(i32 %a.tr, i32 %b.tr)
  %cmp6 = icmp eq i32 %cond5, 0
  br i1 %cmp6, label %cleanup9, label %if.end

if.end:                                           ; preds = %tailrecurse
  %rem = srem i32 %cond, %cond5
  %cmp7 = icmp eq i32 %rem, 0
  br i1 %cmp7, label %cleanup9, label %tailrecurse

cleanup9:                                         ; preds = %if.end, %tailrecurse
  %retval.1 = phi i32 [ %cond, %tailrecurse ], [ %cond5, %if.end ]
  ret i32 %retval.1
}

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %argc, ptr nocapture noundef readnone %argv) local_unnamed_addr #2 {
entry:
  %N = alloca i32, align 4
  %n = alloca i32, align 4
  %0 = tail call ptr (ptr, ...) @objc_lookup_class(ptr nonnull @0) #7
  %1 = tail call ptr @objc_msg_lookup(ptr %0, ptr nonnull @.objc_selector_list) #7, !GNUObjCMessageSend !5
  %call = tail call ptr %1(ptr noundef %0, ptr noundef nonnull @.objc_selector_list) #7, !GNUObjCMessageSend !5
  %2 = tail call ptr @objc_msg_lookup(ptr %call, ptr nonnull getelementptr inbounds ([4 x { ptr, ptr }], ptr @.objc_selector_list, i64 0, i64 2)) #7, !GNUObjCMessageSend !6
  %call1 = tail call ptr %2(ptr noundef %call, ptr noundef nonnull getelementptr inbounds ([4 x { ptr, ptr }], ptr @.objc_selector_list, i64 0, i64 2)) #7, !GNUObjCMessageSend !6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %N) #7
  %call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %N)
  %3 = load i32, ptr %N, align 4, !tbaa !7
  %conv = sext i32 %3 to i64
  %mul = shl nsw i64 %conv, 2
  %call3 = call noalias ptr @malloc(i64 noundef %mul) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #7
  %call422 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
  %cmp.not23 = icmp eq i32 %call422, -1
  br i1 %cmp.not23, label %while.end, label %while.body

while.body:                                       ; preds = %entry, %while.body
  %indvars.iv = phi i64 [ %indvars.iv.next, %while.body ], [ 0, %entry ]
  %4 = load i32, ptr %n, align 4, !tbaa !7
  %arrayidx = getelementptr inbounds i32, ptr %call3, i64 %indvars.iv
  store i32 %4, ptr %arrayidx, align 4, !tbaa !7
  %indvars.iv.next = add nuw i64 %indvars.iv, 1
  %call4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
  %cmp.not = icmp eq i32 %call4, -1
  br i1 %cmp.not, label %while.end.loopexit, label %while.body

while.end.loopexit:                               ; preds = %while.body
  %.pre = load i32, ptr %call3, align 4, !tbaa !7
  br label %while.end

while.end:                                        ; preds = %while.end.loopexit, %entry
  %5 = phi i32 [ %.pre, %while.end.loopexit ], [ undef, %entry ]
  %6 = load i32, ptr %N, align 4, !tbaa !7
  %cmp825 = icmp sgt i32 %6, 1
  br i1 %cmp825, label %for.body.preheader, label %for.cond.cleanup

for.body.preheader:                               ; preds = %while.end
  %wide.trip.count = zext i32 %6 to i64
  br label %for.body

for.cond.cleanup:                                 ; preds = %gcd.exit, %while.end
  %g.0.lcssa = phi i32 [ %5, %while.end ], [ %retval.1.i, %gcd.exit ]
  %call14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %g.0.lcssa)
  call void @free(ptr noundef %call3) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %N) #7
  %7 = call ptr @objc_msg_lookup(ptr %call1, ptr nonnull getelementptr inbounds ([4 x { ptr, ptr }], ptr @.objc_selector_list, i64 0, i64 1)) #7, !GNUObjCMessageSend !11
  call void %7(ptr noundef %call1, ptr noundef nonnull getelementptr inbounds ([4 x { ptr, ptr }], ptr @.objc_selector_list, i64 0, i64 1)) #7, !GNUObjCMessageSend !11
  ret i32 0

for.body:                                         ; preds = %for.body.preheader, %gcd.exit
  %indvars.iv29 = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next30, %gcd.exit ]
  %g.026 = phi i32 [ %5, %for.body.preheader ], [ %retval.1.i, %gcd.exit ]
  %arrayidx11 = getelementptr inbounds i32, ptr %call3, i64 %indvars.iv29
  %8 = load i32, ptr %arrayidx11, align 4, !tbaa !7
  br label %tailrecurse.i

tailrecurse.i:                                    ; preds = %if.end.i, %for.body
  %a.tr.i = phi i32 [ %8, %for.body ], [ %rem.i, %if.end.i ]
  %b.tr.i = phi i32 [ %g.026, %for.body ], [ %cond5.i, %if.end.i ]
  %cond.i = call i32 @llvm.smax.i32(i32 %a.tr.i, i32 %b.tr.i)
  %cond5.i = call i32 @llvm.smin.i32(i32 %a.tr.i, i32 %b.tr.i)
  %cmp6.i = icmp eq i32 %cond5.i, 0
  br i1 %cmp6.i, label %gcd.exit, label %if.end.i

if.end.i:                                         ; preds = %tailrecurse.i
  %rem.i = srem i32 %cond.i, %cond5.i
  %cmp7.i = icmp eq i32 %rem.i, 0
  br i1 %cmp7.i, label %gcd.exit, label %tailrecurse.i

gcd.exit:                                         ; preds = %tailrecurse.i, %if.end.i
  %retval.1.i = phi i32 [ %cond.i, %tailrecurse.i ], [ %cond5.i, %if.end.i ]
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count
  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
}

declare ptr @objc_lookup_class(ptr, ...) local_unnamed_addr

declare ptr @objc_msg_lookup(ptr, ptr) local_unnamed_addr

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

define internal void @.objc_load_function() {
entry:
  tail call void (ptr, ...) @__objc_exec_class(ptr nonnull @5)
  ret void
}

declare void @__objc_exec_class(ptr, ...) local_unnamed_addr

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

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

attributes #0 = { nofree nosync nounwind memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!"alloc", !"", i1 false}
!6 = !{!"init", !"", i1 false}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"drain", !"", i1 false}
