Problem:
 Score : 200 points    Problem Statement Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N .
Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N) .  Also, there are M kinds of drinks offered to the contestants, numbered 1 through M .
If Joisino takes drink i(1≦i≦M) , her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.
It does not affect the time to solve the other problems.  A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.      Constraints  All input values are integers.  1≦N≦100  1≦T_i≦10^5  1≦M≦100  1≦P_i≦N  1≦X_i≦10^5         Input The input is given from Standard Input in the following format:  N  T_1  T_2  ...  T_N  M  P_1  X_1  P_2  X_2  :  P_M  X_M       Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.        Sample Input 1 3
2 1 4
2
1 1
2 3      Sample Output 1 6
9  If Joisino takes drink 1 , the time it takes her to solve each problem will be 1 , 1 and 4 seconds, respectively, totaling 6 seconds.  If Joisino takes drink 2 , the time it takes her to solve each problem will be 2 , 3 and 4 seconds, respectively, totaling 9 seconds.       Sample Input 2 5
7 2 3 8 5
3
4 2
1 7
4 13      Sample Output 2 19
25
30

Solution (Python):
import copy
N = input()
T = list(map(int, input().split()))
M = int(input())
time = []
for i in range(M):
    t = copy.copy(T)
    P, X = map(int, input().split())
    t[P-1] = X

    sum = 0
    for j in t:
        sum += j
    time.append(sum)

for s in time:
    print(s)

Solution (Python):
n = int(input())
t_list=[int(s) for s in input().split()]
total=sum(t_list)

m = int(input())
drink=[]
for _ in range(m):
    p,x=map(int,input().split())
    drink.append((p,x))

for p,x in drink:
    print(total - t_list[p-1] + x)

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())

sum = 0
for i in range(N):
    sum += T[i]

D = []
for i in range(M):
    x = list(map(int,input().split()))
    D.append(x)

for i in range(M):
    sumx = 0
    sumx = sum-(T[D[i][0]-1]-D[i][1])
    print(sumx)

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    a.append(arr)
for i in a:
    t_new = [j for j in t]
    if i[0] <= n:t_new[i[0]-1] = i[1]
    print(sum(t_new))

Solution (Python):
N = int(input())
*T, = map(int, input().split())
M = int(input())

for i in range(M):
    p, x = map(int, input().split())
    T2 = T.copy()
    T2[p-1] = x
    print(sum(T2))

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
ans=sum(t)
for i in range(m):
    p,x=map(int,input().split())
    print(ans+(x-t[p-1]))

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    print(sum(t)-t[p-1]+x)

Solution (Python):
N = int(input())
time = list(map(int, input().split()))
M = int(input())

eff = list(range(M*2))

for i in range(M):
    eff[i*2], eff[(i*2)+1] = map(int, input().split())
    
for i in range(M):
    total = sum(time) - time[eff[i*2]-1] + eff[(i*2)+1]
    print(total)

Solution (Python):
n=int(input())
p=input().rstrip().split(' ')
o=int(input())
for i in range(0,o):
    d=0;
    C=list(p)
    h=input().rstrip().split(' ')
    C[int(h[0])-1] = int(h[1])
    for j in range(0,len(p)):
        d=d+int(C[j])
    print(d)

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
Ts = nl()
M = n()

res = []
for i in range(M):
    P, X = nl()
    TD = Ts[:]
    TD[P-1] = X
    res.append(sum(TD))

for i in range(M):
    print(res[i])

Solution (Python):
def abc():
    input()
    t = list(map(int, input().split()))
    s = sum(t)
    m = int(input())
    for i in range(m):
        p, x = map(int, input().split())
        b = t[p-1]
        print(s - b + x)


abc()

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
total = 0
for i in T:
    total += i

for _ in range(M):
    P, X = map(int, input().split())
    print (total - T[P-1] + X)

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
p = []
x = []
for i in range(m):
    p_i,x_i = map(int,input().split())
    p.append(p_i)
    x.append(x_i)
s = sum(t)
for i in range(m):
    print(s - t[p[i]-1] + x[i])

Solution (Python):


N = int(input())
T = list(map(int,input().split()))
t = sum(T)
M = int(input())
P = []
X = []
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

for i in range(M):
    s = t - T[P[i]-1] + X[i]
    print(s)

Solution (Python):

N = int(input())
lst_T = input().split()
for i in range(len(lst_T)):
    lst_T[i] = int(lst_T[i])
M = int(input())

lst_D = []

for i in range(M):
    lst_D.append(input().split())
    lst_D[i][0] = int(lst_D[i][0])
    lst_D[i][1] = int(lst_D[i][1])

for i in range(M):
    W = lst_T[(lst_D[i][0])-1]
    lst_T[(lst_D[i][0])-1] = lst_D[i][1]
    print(sum(lst_T))
    lst_T[(lst_D[i][0]) - 1] = W

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())

PX = []
drink_list = list()
for i in range(M):
    PX.append(input().split())
    
    PX[i][0] = int(PX[i][0])
    PX[i][1] = int(PX[i][1])

for i in range(M):
    drink_list.append(sum(T) -T[PX[i][0]-1] + PX[i][1])
    print(drink_list[i])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
D = []

for i in range(M):
    D.append(list(map(int, input().split())))

for d in D:
    print(sum(T) - T[d[0]-1] + d[1])

Solution (Python):
N = input()
T = list(map(int, input().split()))
M = input()
sum = sum(T)
PX = []
ansList = list()
for i in range(int(M)):
    PX.append(list(map(int, input().split())))
for i in range(int(M)):
    ansList.append(sum - (T[PX[i][0]-1] - PX[i][1]))
    print(ansList[i])

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
default=sum(t)
for i in range(m):
  a,b=map(int,input().split())
  print(default-t[a-1]+b)

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())

t_sum = sum(T)

for i in range(M):
    p,x = map(int,input().split())
    print(t_sum-T[p-1]+x)

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
T = list(map(int, sys.stdin.readline().split()))
M = int(sys.stdin.readline())
P, X = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

s = sum(T)
for p, x in zip(P, X):
    print(s - T[p-1] + x)

Solution (Python):
n = int(input())
t = list(map(int, input().split(' ')))
m = int(input())
for _ in range(m):
    t_ = t.copy()
    p, x = map(int, input().split(' '))
    t_[p-1] = x
    print(sum(t_))

Solution (Python):
N = int(input())
T = [int(i) for i in input().split()]
su = sum(T)
M = int(input())
for p, x in (map(int, input().split()) for _ in range(M)):
    print(su - T[p - 1] + x)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int,input().split())) for  _ in range(M)]
for i in P:
        print(sum(T)-T[i[0]-1]+i[1])

Solution (Python):
n = int(input())
dat_t = list(map(int, input().split()))
m = int(input())
dat_d = []
s = sum(dat_t)
for i in range(m):
    p,x = map(int, input().split())
    print(s - dat_t[p - 1] + x)

Solution (Python):
n_t = int(input())
t_lis = list(map(int,input().split()))
n_d = int(input())
d_lis = []
for _ in range(n_d):
  d_lis.append(list(map(int,input().split())))
d_dif = [0]*n_d
for i,item in enumerate(d_lis):
  d_dif[i] = item[1] - t_lis[item[0]-1]
sum_t = sum(t_lis)
for num in d_dif:
  print(sum_t + num)

Solution (Python):
N=int(input())
T=[0]+[int(i) for i in input().split()]
M=int(input())
P=[]
X=[]
for i in range(M):
    p,x=map(int,input().split())
    P.append(p)
    X.append(x)

T_sum=sum(T)

for i in range(M):
    print(T_sum-T[P[i]]+X[i])

Solution (Python):
N = int(input())
T = [0] + [int(x) for x in input().split()]
M = int(input())
s = sum(T)

answer = []
for _ in range(M):
  a,b = map(int,input().split())
  answer.append(s+b-T[a])

print(*answer,sep='\n')

Solution (Python):
import copy
n = int(input())
t = list(map(int, input().split()))
m = int(input())
for _ in range(m):
    tt = copy.copy(t)
    p, x = map(int, input().split())
    tt[p-1] = x
    print(sum(tt))

Solution (Python):

N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = []
for i in range(M):
    px.append(list(map(int, input().split())))
for i in range(M):
    ans = 0
    ans += sum(T) - T[px[i][0]-1] + px[i][1]
    print(ans)

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
px = [input() for _ in range(m)]

for i in range(m):
    p, x = px[i].split()
    print(sum(t) - t[int(p)-1] + int(x))

Solution (Python):
N = int(input())
T = list(map(int, input().split()))

M = int(input())

for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - T[P - 1] + X)

Solution (Python):
import copy
n=int(input())
t=list(map(int,input().split()))

pro=[]
m=int(input())

for i in range(m):
    pro.append(list(map(int,input().split())))

for j in range(m):
    ans=copy.deepcopy(t)
    x=pro[j][0]
    p=pro[j][1]
    ans[x-1]=p
    print(sum(ans))

Solution (Python):
import copy
n=int(input())

pro=list(map(int,input().split()))


m=int(input())

drinks=[]
for i in range(m):
    drinks.append(list(map(int,input().split())))

for i in range(m):
    ans=copy.deepcopy(pro)
    ans[drinks[i][0]-1]=drinks[i][1]
    print(sum(ans))

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
pxlist = []
for i in range(m):
    px = list(map(int, input().split()))
    pxlist.append(px)
sumlist = []
for i in range(m):
    sum = 0
    for j in range(n):
        if j == pxlist[i][0]-1:
            sum += pxlist[i][1]
        else:
            sum += int(t[j])
    sumlist.append(sum)
    print(sumlist[i])

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
for i in range(m):
  p[i],x[i]=map(int,input().split())
fulltime=sum(t)
for i in range(m):
  print(fulltime-(t[p[i]-1]-x[i]))

Solution (Python):
import copy

n=int(input())
t=list(map(int,input().split()))

m=int(input())

drinks=[]
for i in range(m):
    drinks.append(list(map(int,input().split())))

for k in range(m):
    p=drinks[k][0]
    x=drinks[k][1]
    answer=copy.deepcopy(t)
    answer[p-1]=x
    print(sum(answer))

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [0]*m
x = [0]*m
for i in range(m):
    p[i],x[i] = map(int,input().split())

for j in range(m):
    print(sum(t)+x[j]-t[p[j]-1])

Solution (Python):
n = int(input())
tn = list(map(int, input().split()))
total = sum(tn)

m = int(input())
for i in range(m):
  p, x = map(int, input().split())
  print(total - tn[p-1] + x)

Solution (Python):
N=int(input())
T=list(map(int,input().split()))
M=int(input())
Drink=[list(map(int,input().split())) for _ in range(M)]
answer=sum(T)
for i in range(M):
    p=Drink[i][0]
    x=Drink[i][1]
    print(answer-T[p-1]+x)

Solution (Python):
import copy
N=int(input())
T=list(map(int,input().split()))
M=int(input())
Drink=[list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    p=Drink[i][0]
    x=Drink[i][1]
    answer=copy.deepcopy(T)
    answer[p-1]=x
    print(sum(answer))

Solution (Python):
n = int(input())
time = [i for i in map(int,input().split())]
m = int(input())
ch_time = []
for i in range(m):
    ch_time.append([i for i in map(int,input().split()) ])

for i in range(m) :
    num = ch_time[i][0]
    dif = ch_time[i][1] - time[num-1]
    print("{}".format(sum(time)+dif))

Solution (Python):
n=int(input())
T=list(map(int,input().split()))
m=int(input())
PX=[]
for i in range(m):
  p,x=map(int,input().split())
  PX.append((p,x))
for i in range(m):
  print(sum(T)-T[PX[i][0]-1]+PX[i][1])

Solution (Python):
import copy

n = int(input())
t = list(map(int, input().split()))
m = int(input())
for j in range(m):
    ans = copy.copy(t)
    p,x = map(int, input().split())
    ans[p-1] = x
    print(sum(ans))

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for _ in range(M):
  p,x = map(int,input().split())
  P.append(p)
  X.append(x)

sumT = sum(T)

for p,x in zip(P,X):
  print(sumT - (T[p-1]-x))

Solution (Python):

"""
B - Contest with Drinks Easy
https://atcoder.jp/contests/abc050/tasks/abc050_b

"""
import sys


def solve(N, T, M, drinks):
    total = sum(T)
    ans = []
    for p, x in drinks:
        ans.append(total + x - T[p-1])
    return ans


def main(args):
    N = int(input())
    T = [int(t) for t in input().split()]
    M = int(input())
    drinks = [[int(i) for i in input().split()] for _ in range(M)]
    ans = solve(N, T, M, drinks)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
import copy
n = int(input())
t = list(map(int, input().split()))
m = int(input())
for _ in range(m):
    tt = copy.copy(t)
    p, x = map(int, input().split())
    tt[p-1] = x
    print(sum(tt))

Solution (Python):
ans=[]
n=int(input())
t=list(map(int,input().split()))

m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    a=sum(t)+x-t[p-1]
    ans.append(a)
for o in ans:
    print(o)

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []

for i in range(m):
	l = list(map(int,input().split()))
	p.append(l[0])
	x.append(l[1])

for (a,b) in zip(p,x):
	nums = 0
	for i in t:
		nums += i
	nums -= t[a-1]-b
	print(nums)

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
sumt = sum(t)
m = int(input())
l = []
for i in range(m):
    p, x = map(int,input().split())
    a = sum(t)+x-t[p-1]
    l.append(a)
for o in l:
    print(o)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
sum_T = sum(T)

for i in range(M):
    p, x = map(int, input().split())
    ans = sum_T - T[p - 1] + x
    print(ans)

Solution (Python):
n = int(input())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
	p, t = [ int(v) for v in input().split() ]
	print(total_time - time_list[p-1] + t)

Solution (Python):
n = int(input())

t = list(map(int, input().split()))
total_time = sum(t)

m = int(input())

pxs = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    p, x = pxs[i]
    print(total_time - t[p - 1] + x)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 


N = int(input())
T = [int(i) for i in input().split()]
M = int(input()) 
PM = [[] for i in range(M)]
for i in range(M):
    PM[i] = [int(i) for i in input().split()]

solve_time = sum(T)
for i in range(M):
    p,m = PM[i]
    print(solve_time-T[p-1]+m)

Solution (Python):
N=int(input())
T=list(map(int,input().split()))
[print(sum([m[1] if m[0]==n+1 else T[n] for n in range(N)])) for m in [list(map(int,input().split())) for i in range(int(input()))]]

Solution (Python):
N=int(input())
T=[i for i in list(map(int,input().split()))]
M=int(input())
Px=[list(map(int,input().split())) for i in range(M)]
[print(sum([m[1] if m[0]==n+1 else T[n] for n in range(N)])) for m in Px]

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
ans = []
for i in range(m):
    p,x = map(int,input().split())
    tot = sum(t)
    tot = tot  -  t[p - 1]+x
    ans.append(tot)
for i in ans:
    print(i)

Solution (Python):
N=int(input())
t=list(map(int,input().split()))
M=int(input())
for _ in range(M):
    x,y=map(int,input().split())
    print(sum(t)-t[x-1]+y)

Solution (Python):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    t = f()

    m = f()[0]
    drinks = [f() for i in range(m)]

    tt = sum(t)
    for some in drinks:
        print(tt - (t[some[0]-1] - some[1]))

solve()

Solution (Python):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
PM = [[int(i) for i in input().split()] for j in range(M)]

for i,j in PM:
    print(sum(T[:i-1]+T[i:])+j)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
ans=[]
for i in range(m):
    p,x=map(int,input().split())
    ans.append(sum(t)-(t[p-1]-x))
for i in range(m):
    print(ans[i])

Solution (Python):
quiz_number = int(input())
time = list(map(int,input().split()))
drink = int(input())
quiz_time = [list(map(int,input().split())) for i in range(drink)]

for i in range(drink):
    sum = 0
    quiz = quiz_time[i][0]
    change_time = quiz_time[i][1]
    for j in range(quiz_number):
        sum += time[j]
    sum = sum - time[quiz-1] + change_time
    print(sum)

Solution (Python):
n = int(input())

t = [int(s) for s in input().split()]
T = t
m = int(input())

for i in range(m):
    

    x,y = list(map(int,input().split()))
    print(sum(t) + y - t[x-1])

Solution (Python):
import copy
n = int(input())

t = list(map(int, input().split()))
m = int(input())

for i in range(m):
    copy_t = copy.copy(t)
    p, x  = map(int, input().split())
    copy_t[p-1] = x
    print(sum(copy_t))

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
ans = sum(t)
m = int(input())
p = []
x = []
for i in range(m):
    p,x = map(int,input().split())
    print(ans-t[p-1]+x)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
ans = 0
for i in range(m):
    p, x = map(int, input().split())
    j = t[p-1]
    t[p-1] = x
    print(sum(t))
    t[p-1] = j

Solution (Python):
n = int(input())
ts = list(map(int, input().split()))
m = int(input())

sumt = sum(ts)
for _ in range(m):
    p, x = list(map(int, input().split()))
    print(sumt + x - ts[p-1])

Solution (Python):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
sumT = sum(T)

for p,x in [tuple([int(i) for i in input().split()]) for i in range(M)]:
    print(sumT-(T[p-1]-x))

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
s = sum(T)

M = int(input())
for _ in range(M):
	p, x = map(int, input().split())
	print(s - T[p-1] + x)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for i in range(m)]
sum_t = sum(t)
for i in px:
  key, value = i[0]-1, i[1] 
  ans = sum_t - (t[key]-value)
  print(ans)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for i in range(m)]

sum_t = sum(t)
for i, j in p:
    print(sum_t - t[i-1] + j)

Solution (Python):
n = int(input())
problems = list(map(int,input().split()))
sum_time = sum(problems)
m = int(input())
out = []
for _ in range(m):
    key,time = map(int,input().split())
    out.append(sum_time-problems[key-1]+time)

for time in out:
    print(time)

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
PX = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
for i in range(M):
    drink_i = PX[i][0]-1
    print(PX[i][1]+sum(T[:drink_i]+T[drink_i+1:]))

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
T = sum(t)
m = int(input())
ans = []
for i in range(m):
    p, x = map(int, input().split())
    ans.append(T - t[p - 1] + x)
for a in ans:
    print(a)

Solution (Python):
import copy
input()
t=[0]+list(map(int,input().split()))
for i in range(int(input())):
    ans=copy.deepcopy(t)
    p,x=map(int,input().split())
    ans[p]=x
    print(sum(ans))

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
ans = 0
for i in range(m):
    p, x = map(int, input().split())
    j = t[p-1]
    t[p-1] = x
    print(sum(t))
    t[p-1] = j

Solution (Python):
n = int(input())
t = list(input().split())
m = int(input())
max_time = sum(int(x) for x in t)
for i in range(m):
    a,b = map(int,input().split())
    print(max_time - (int(t[a-1]) - b))

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
l=list(list(map(int,input().split())) for i in range(m))

s=sum(t)
for i in range(m):
    print(s+l[i][1]-t[l[i][0]-1])

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())

ans = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    print(ans - t[p-1] + x)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = list()

x = list()

for i in range(m):
    a, b = map(int, input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    count = 0
    for j in range(n):
        z = p[i] -1
        if (j == z):
            count += x[i]

        else:
            count += t[j]
    print(count)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
for i in range(int(input())):
  p, x = map(int, input().split())
  print(sumT-T[p-1]+x)

Solution (Python):
import copy

n = int(input())
ts = list(map(int, input().split()))
m = int(input())

for i in range(m):
  p, x = map(int, input().split())
  ts_i = copy.deepcopy(ts)
  ts_i[p-1] = x
  print(sum(ts_i))

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    pi,xi = map(int,input().split())
    p.append(pi)
    x.append(xi)
ans = sum(t)
for i in range(m):
    print(ans-t[p[i]-1]+x[i])

Solution (Python):
input()
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - T[P-1] + X)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
d = 0
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - T[P-1] + X)

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = list(list(map(int,input().split())) for i in range(M))
time = sum(T)
for p,x in PX:
    print(time - (T[p-1]-x))

Solution (Python):
N=int(input())
T=list(map(int,input().split(" ")))
s=sum(T)
M=int(input())
P=[]
for z in range(M):
  P.append(list(map(int,input().split(" "))))

for z in P:
  print(s-T[z[0]-1]+z[1])

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
st=sum(t)
m=int(input())
px=[[int(i) for i in input().split()] for j in range(m)]
for i in range(m):
    print(st+px[i][1]-t[px[i][0]-1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
sumt = sum(T)
M = int(input())
for i in range(M):
  p, x = map(int, input().split())
  print(sumt - (T[p-1] - x))

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X = [], []
for i in range(M):
    _p, _x = map(int, input().split())
    P.append(_p)
    X.append(_x)

sm = sum(T)

for i in range(M):
    print(sm + X[i] - T[P[i]-1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    Pi, Xi = map(int, input().split())
    P.append(Pi)
    X.append(Xi)

S = sum(T)
for i in range(M):
    print(S - (T[P[i] - 1] - X[i]))

Solution (Python):
l=lambda:map(int,input().split())
l()
*T,=l()
*M,=l()
S=sum(T)
for P,X in[l() for _ in [0]*M[0]]:print(S-T[P-1]+X)

Solution (Python):
N=int(input())
*T,=map(int,input().split())
M=int(input())
PX=[list(map(int,input().split())) for _ in [0]*M]
S=sum(T)
for P,X in PX:print(S-T[P-1]+X)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    time = 0
    ls = PX[i]
    for j in range(N):
        if ls[0] == j+1:
            time += ls[1]
        else:
            time += T[j]
    print(time)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    time = 0
    ls = PX[i]
    for j in range(N):
        if ls[0] == j+1:
            time += ls[1]
        else:
            time += T[j]
    print(time)

Solution (Python):
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N=int(input())
T=ipt()
M=int(input())
PX=ipt(M)

for i in range(M):
    print(sum(T) + PX[i][1] - T[PX[i][0]-1])

Solution (Python):
_ = input()
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
  P, X = map(int, input().split())
  ans = sum(T[:P-1])+sum(T[P:])+X
  print(ans)

Solution (Python):
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = [[int(x) for x in input().split()]for _ in range(M)]

ans0 = sum(T)
for i in PX:
    print(ans0-T[i[0]-1]+i[1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for i in range(M)] 
for i in range(M):
    print(sum(T)-T[P[i][0]-1]+P[i][1])

Solution (Python):
def getlist():
  return list(map(int, input().split()))

n = int(input())
times = getlist()
ans = sum(times)
k = int(input())
for i in range(k):
  a,b = getlist()
  print(ans - times[a-1] + b)

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
for mi in range(m):
  p, x = [int(i) for i in input().split()]
  print(sum(t)-t[p-1]+x)

Solution (Python):


def solve(N, T, M, P, X):
    for i in range(M):
        print(sum(T) - T[P[i]] + X[i])

if __name__ == '__main__': 
    N = int(input())
    T = [int(t) for t in input().split()]
    M = int(input())
    P, X = [], []
    for i in range(M):
        p, x = map(int, input().split())
        P.append(p-1)
        X.append(x)

    solve(N, T, M, P, X)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=list(list(map(int,input().split()))  for _ in range(m))
total=sum(t)
for i in range(m):
    print(total-t[px[i][0]-1]+px[i][1])

Solution (Python):
n = int(input())
T = [int(i) for i in input().split()]
m = int(input())
s = sum(T)
for _ in range(m):
    p, x = [int(i) for i in input().split()]
    print(s-T[p-1]+x)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    l = t[:]
    num = int(px[i][0]-1)
    l[num] = px[i][1]
    print(sum(l))

Solution (Python):
N = int(input())
T = list(map(int,input().split(" ")))
M = int(input())
P = [0]*M
X = [0]*M
s = sum(T)
for i in range(M):
    P[i],X[i]=map(int,input().split(" "))
    X[i] -= T[P[i]-1]
    X[i] += s

for i in range(M):
    print(X[i])

Solution (Python):
N=int(input())
T=list(map(int,input().split()))
M=int(input())
P=[]
X=[]
for k in range(M):
    p,x=map(int,input().split())
    P.append(p)
    X.append(x)

for h in range(M):
    time=sum(T)-T[P[h]-1]+X[h]
    print(time)

Solution (Python):
import copy

n = int(input())
t = [int(n) for n in input().split()]


m = int(input())
px = []
for i in range(m):
    px.append([int(n) for n in input().split()])

for p, x in px:
    t_ = copy.copy(t)
    t_[p-1] = x
    print(sum(t_))

Solution (Python):
n=int(input())
t=[int(x) for x in input().split()]
m=int(input())
p=[]
x=[]
for i in range(m):
    p_,x_=map(int,input().split())
    p.append(p_)
    x.append(x_)
for i in range(m):
    tm=sum(t)-t[p[i]-1]+x[i]
    print(tm)

Solution (Python):
import copy
N = int(input())
T = list(map(int, input().split()))
copy_T = copy.deepcopy(T)
M = int(input())
P_list = []
X_list = []
lists = []
for i in range(M):
    P, X = map(int, input().split())
    P_list.append(P)
    X_list.append(X)
for i in range(M):
    copy_T = copy.deepcopy(T)
    tmp = P_list[i]
    copy_T[tmp - 1] = X_list[i]
    print(sum(copy_T))

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for _ in['0']*m:
  p,x=map(int,input().split())
  print(sum(t)-t[p-1]+x)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
for i in range(m):
    p,x=map(int,input().split())
    drink.append([p,x])

for i in range(m):
    s=t.copy()
    s[((drink[i][0])-1)]=drink[i][1]
    print(sum(s))

Solution (Python):
N=int(input())
T=list(map(int,input().split()))
M=int(input())
P=[]
X=[]
for i in range(M):
    p,x=map(int,input().split())
    P.append(p)
    X.append(x)
s = sum(T)
for i in range(M):
    print(s-T[P[i]-1]+X[i])

Solution (Python):
n=int(input())
t=list(map(int, input().split()))

for a in range(int(input())):
    x, y=map(int, input().split())
    print(sum(t)+y-t[x-1])

Solution (Python):
n=int(input())
t=list(map(int, input().split()))
sum=0
for i in t:
    sum+=i

for a in range(int(input())):
    x, y=map(int, input().split())
    print(sum+y-t[x-1])

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for i in range(m)]
for i in px:
	print(sum(t)-t[i[0]-1]+i[1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
D = [list(map(int, input().split())) for _ in range(M)]

sumt = sum(T)
for d in D:
    print(sumt-(T[d[0]-1]-d[1]))

Solution (Python):

n = int(input())
lst = list(map(int, input().rstrip().split()))
m = int(input())
drinks = [list(map(int, input().rstrip().split())) for _ in range(m)]
total = sum(lst)

for i in drinks:
    print(total - lst[i[0] - 1] + i[1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
x = int(input())

res = sum(a)

for i in range(x):
  c, d = (int(_) for _ in input().split())
  print(res + d - a[c-1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]

for P, X in PX:
    print(sum(T) - T[P - 1] + X)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
for i in range(m):
    p, x = map(int, input().split())
    tem = t.copy()
    tem[p-1] = x
    print(sum(tem))

Solution (Python):
import sys

n = int(input())
Tn = list(map(int, sys.stdin.readline().rstrip().split()))
m = int(input())
px = [[0,0] for i in range(m)]
for i in range(m):
  px[i] = list(map(int, input().split()))

sm = sum(Tn)
for i in range(m):
  print(sm-Tn[px[i][0]-1]+px[i][1])