#import <stdio.h>
int main() {
    int n,m;
    int T[200] = {0};
    int P[200] = {0};
    int X[200] = {0};
    scanf("%d", &n);
    for(int i=0;i<n;i++) {
        int t;
        scanf("%d", &t);
        T[i] = t;
    }
    scanf("%d", &m);
    for(int j=0;j<m;j++) {
        int p, x;
        scanf("%d %d", &p,&x);
        P[j] = p;
        X[j] = x;
    }
    for(int j=0;j<m;j++) {
        int count = 0;
        for(int i=0;i<n;i++) {
            count += i==P[j]-1 ? X[j] : T[i];
        }
        printf("%d\n", count);
    }
}

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

@.str = private unnamed_addr constant [3 x i8] c"%d\00", align 1
@.str.1 = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
  %n = alloca i32, align 4
  %m = alloca i32, align 4
  %T = alloca [200 x i32], align 16
  %P = alloca [200 x i32], align 16
  %X = alloca [200 x i32], align 16
  %t = alloca i32, align 4
  %p = alloca i32, align 4
  %x = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %m) #4
  call void @llvm.lifetime.start.p0(i64 800, ptr nonnull %T) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800) %T, i8 0, i64 800, i1 false)
  call void @llvm.lifetime.start.p0(i64 800, ptr nonnull %P) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800) %P, i8 0, i64 800, i1 false)
  call void @llvm.lifetime.start.p0(i64 800, ptr nonnull %X) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(800) %X, i8 0, i64 800, i1 false)
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n)
  %0 = load i32, ptr %n, align 4, !tbaa !5
  %cmp51 = icmp sgt i32 %0, 0
  br i1 %cmp51, label %for.body, label %for.cond.cleanup

for.cond.cleanup:                                 ; preds = %for.body, %entry
  %call2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %m)
  %1 = load i32, ptr %m, align 4, !tbaa !5
  %cmp453 = icmp sgt i32 %1, 0
  br i1 %cmp453, label %for.body6, label %for.cond.cleanup18

for.body:                                         ; preds = %entry, %for.body
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %t) #4
  %call1 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %t)
  %2 = load i32, ptr %t, align 4, !tbaa !5
  %arrayidx = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv
  store i32 %2, ptr %arrayidx, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %t) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %3 = load i32, ptr %n, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %cmp = icmp slt i64 %indvars.iv.next, %4
  br i1 %cmp, label %for.body, label %for.cond.cleanup

for.cond16.preheader:                             ; preds = %for.body6
  %5 = icmp sgt i32 %8, 0
  br i1 %5, label %for.cond21.preheader, label %for.cond.cleanup18

for.body6:                                        ; preds = %for.cond.cleanup, %for.body6
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %for.body6 ], [ 0, %for.cond.cleanup ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %p) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %x) #4
  %call7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %p, ptr noundef nonnull %x)
  %6 = load i32, ptr %p, align 4, !tbaa !5
  %arrayidx9 = getelementptr inbounds [200 x i32], ptr %P, i64 0, i64 %indvars.iv61
  store i32 %6, ptr %arrayidx9, align 4, !tbaa !5
  %7 = load i32, ptr %x, align 4, !tbaa !5
  %arrayidx11 = getelementptr inbounds [200 x i32], ptr %X, i64 0, i64 %indvars.iv61
  store i32 %7, ptr %arrayidx11, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %x) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %p) #4
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %8 = load i32, ptr %m, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %cmp4 = icmp slt i64 %indvars.iv.next62, %9
  br i1 %cmp4, label %for.body6, label %for.cond16.preheader

for.cond21.preheader:                             ; preds = %for.cond16.preheader, %for.cond.cleanup23
  %indvars.iv67 = phi i64 [ %indvars.iv.next68, %for.cond.cleanup23 ], [ 0, %for.cond16.preheader ]
  %10 = load i32, ptr %n, align 4, !tbaa !5
  %cmp2255 = icmp sgt i32 %10, 0
  br i1 %cmp2255, label %for.body24.lr.ph, label %for.cond.cleanup23

for.body24.lr.ph:                                 ; preds = %for.cond21.preheader
  %arrayidx26 = getelementptr inbounds [200 x i32], ptr %P, i64 0, i64 %indvars.iv67
  %11 = load i32, ptr %arrayidx26, align 4, !tbaa !5
  %sub = add nsw i32 %11, -1
  %arrayidx29 = getelementptr inbounds [200 x i32], ptr %X, i64 0, i64 %indvars.iv67
  %12 = zext i32 %sub to i64
  %wide.trip.count = zext i32 %10 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %13 = icmp ult i32 %10, 4
  br i1 %13, label %for.cond.cleanup23.loopexit.unr-lcssa, label %for.body24.lr.ph.new

for.body24.lr.ph.new:                             ; preds = %for.body24.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %for.body24

for.cond.cleanup18:                               ; preds = %for.cond.cleanup23, %for.cond.cleanup, %for.cond16.preheader
  call void @llvm.lifetime.end.p0(i64 800, ptr nonnull %X) #4
  call void @llvm.lifetime.end.p0(i64 800, ptr nonnull %P) #4
  call void @llvm.lifetime.end.p0(i64 800, ptr nonnull %T) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %m) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #4
  ret i32 0

for.cond.cleanup23.loopexit.unr-lcssa:            ; preds = %for.body24, %for.body24.lr.ph
  %add.lcssa.ph = phi i32 [ undef, %for.body24.lr.ph ], [ %add.3, %for.body24 ]
  %indvars.iv64.unr = phi i64 [ 0, %for.body24.lr.ph ], [ %indvars.iv.next65.3, %for.body24 ]
  %count.056.unr = phi i32 [ 0, %for.body24.lr.ph ], [ %add.3, %for.body24 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %for.cond.cleanup23, label %for.body24.epil

for.body24.epil:                                  ; preds = %for.cond.cleanup23.loopexit.unr-lcssa, %for.body24.epil
  %indvars.iv64.epil = phi i64 [ %indvars.iv.next65.epil, %for.body24.epil ], [ %indvars.iv64.unr, %for.cond.cleanup23.loopexit.unr-lcssa ]
  %count.056.epil = phi i32 [ %add.epil, %for.body24.epil ], [ %count.056.unr, %for.cond.cleanup23.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %for.body24.epil ], [ 0, %for.cond.cleanup23.loopexit.unr-lcssa ]
  %cmp27.epil = icmp eq i64 %indvars.iv64.epil, %12
  %arrayidx31.epil = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv64.epil
  %cond.in.epil = select i1 %cmp27.epil, ptr %arrayidx29, ptr %arrayidx31.epil
  %cond.epil = load i32, ptr %cond.in.epil, align 4, !tbaa !5
  %add.epil = add nsw i32 %cond.epil, %count.056.epil
  %indvars.iv.next65.epil = add nuw nsw i64 %indvars.iv64.epil, 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 %for.cond.cleanup23, label %for.body24.epil, !llvm.loop !9

for.cond.cleanup23:                               ; preds = %for.cond.cleanup23.loopexit.unr-lcssa, %for.body24.epil, %for.cond21.preheader
  %count.0.lcssa = phi i32 [ 0, %for.cond21.preheader ], [ %add.lcssa.ph, %for.cond.cleanup23.loopexit.unr-lcssa ], [ %add.epil, %for.body24.epil ]
  %call35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %count.0.lcssa)
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %14 = load i32, ptr %m, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %cmp17 = icmp slt i64 %indvars.iv.next68, %15
  br i1 %cmp17, label %for.cond21.preheader, label %for.cond.cleanup18

for.body24:                                       ; preds = %for.body24, %for.body24.lr.ph.new
  %indvars.iv64 = phi i64 [ 0, %for.body24.lr.ph.new ], [ %indvars.iv.next65.3, %for.body24 ]
  %count.056 = phi i32 [ 0, %for.body24.lr.ph.new ], [ %add.3, %for.body24 ]
  %niter = phi i64 [ 0, %for.body24.lr.ph.new ], [ %niter.next.3, %for.body24 ]
  %cmp27 = icmp eq i64 %indvars.iv64, %12
  %arrayidx31 = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv64
  %cond.in = select i1 %cmp27, ptr %arrayidx29, ptr %arrayidx31
  %cond = load i32, ptr %cond.in, align 4, !tbaa !5
  %add = add nsw i32 %cond, %count.056
  %indvars.iv.next65 = or i64 %indvars.iv64, 1
  %cmp27.1 = icmp eq i64 %indvars.iv.next65, %12
  %arrayidx31.1 = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv.next65
  %cond.in.1 = select i1 %cmp27.1, ptr %arrayidx29, ptr %arrayidx31.1
  %cond.1 = load i32, ptr %cond.in.1, align 4, !tbaa !5
  %add.1 = add nsw i32 %cond.1, %add
  %indvars.iv.next65.1 = or i64 %indvars.iv64, 2
  %cmp27.2 = icmp eq i64 %indvars.iv.next65.1, %12
  %arrayidx31.2 = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv.next65.1
  %cond.in.2 = select i1 %cmp27.2, ptr %arrayidx29, ptr %arrayidx31.2
  %cond.2 = load i32, ptr %cond.in.2, align 4, !tbaa !5
  %add.2 = add nsw i32 %cond.2, %add.1
  %indvars.iv.next65.2 = or i64 %indvars.iv64, 3
  %cmp27.3 = icmp eq i64 %indvars.iv.next65.2, %12
  %arrayidx31.3 = getelementptr inbounds [200 x i32], ptr %T, i64 0, i64 %indvars.iv.next65.2
  %cond.in.3 = select i1 %cmp27.3, ptr %arrayidx29, ptr %arrayidx31.3
  %cond.3 = load i32, ptr %cond.in.3, align 4, !tbaa !5
  %add.3 = add nsw i32 %cond.3, %add.2
  %indvars.iv.next65.3 = add nuw nsw i64 %indvars.iv64, 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 %for.cond.cleanup23.loopexit.unr-lcssa, label %for.body24
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

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

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

attributes #0 = { nofree 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { nounwind }

!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 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
