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):
N = int(input())
t = list(map(int, input().split()))
T = [0]
T = T + t

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

Solution (Python):
N = int(input())
t = list(map(int, input().split()))
T = [0]
T = T + t

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

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

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

Solution (Python):
N = int(input())
tList = [int(x) for x in input().split()]
M = int(input())
px = []
for i in range(M):
    p, x = map(int, input().split())
    px.append((p,x))

base = sum(tList)
for p,x in px:
    print(base - tList[p-1] + x)

Solution (Python):
import copy
n = int(input())
times = [int(i) for i in input().split()]
m = int(input())
px = [input().split() for _ in range(m)]
n_times = copy.copy(times)
for p,x in px:
    n_times[int(p)-1] = int(x)
    print(sum(n_times))
    n_times = copy.copy(times)

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

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

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

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)
for i in range(M):
    S = T[:P[i]-1] + T[P[i]:]
    print(X[i] + 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.append(list(map(int,input().split())))

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

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

M = int(input())
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())
t=[int(i) for i in input().split()]
m=int(input())
a=[]
for i in range(m):
    x,y=map(int,input().split())
    a.append(sum(t)-(t[x-1]-y))
    
for i in range(m):
    print(a[i])

Solution (Python):

N = int(input())
T = list(map(int, input().split()))
sum_T = sum(T)
M = int(input())
for _ 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())
for i in range(m):
    p,x=map(int,input().split())
    tmp=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=tmp

Solution (Python):
N=int(input())
t=list(map(int,input().split()))
T=[0]
T=T+t

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

Solution (Python):
"""AtCoder"""

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 range(M):
  ans = 0
  for j in range(N):
    if P[i][0] - 1 == j:
      ans += P[i][1]
    else:
      ans += T[j]
  print(ans)

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

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

result = []
for i in range(M):
  cnt = 0
  P, X = map(int,input().split())
  for j in range(N):
    if(P-1 == j):
      cnt += X
    else:
      cnt += T[j]
  result.append(cnt)
for r in result:
  print(r)

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

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

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())
    s=0
    for j in range(len(t)):
        if j==p-1:
            s+=x
        else:
            s+=t[j]
    print(s)

Solution (Python):
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
l = [[int(j) for j in input().split()] for i in range(m)]
tot = sum(t)
for i in range(m):
    print(tot - t[l[i][0] - 1] + l[i][1])

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

for p, x in PX:
    result = sum(T) - T[p - 1] + x
    print(result)

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

PX = []

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

ans = sum(T)

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

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

Solution (Python):
N = input()
T = map(int, raw_input().split())
S = sum(T)

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

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

Solution (Python):
N=int(input())
T=[0]+[int(i) for i in input().split()]
M=int(input())
drinks=[[int(i) for i in input().split()] for _ in range(M)]
for drink in drinks:
    copyedT=[i for i in T]
    copyedT[drink[0]]=drink[1]
    print(sum(copyedT))

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

m=int(input())
p=[[] for _ in range(m)]
for i in range(m):
    pi,xi=map(int,input().split())
    p[i]=[pi,xi]

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

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

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

Solution (Python):
import copy as c
n=int(input())
a=list(map(int,input().split()))
b=c.deepcopy(a)
m=int(input())
for s in range(m):
  d,f=map(int,input().split())
  a[d-1]=f
  print(sum(a))
  a=c.deepcopy(b)

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

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

Solution (Python):
n = int(input())
*a0, = map(int, input().split())
m = int(input())
for _ in range(m):
    k, b = map(int, input().split())
    a = a0[:]
    a[k-1] = b
    print(sum(a))

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

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

for i in range(m):
    T2 = T.copy()
    T2.pop(px[i][0] - 1)
    T2.append(px[i][1])
    print(sum(T2))

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [None]*M
X = [None]*M

for i in range(M):
  P[i],X[i] = map(int,input().split())

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

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)

sum_T = sum(T)

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

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

for l in L:
  tmp=T[:]
  tmp[l[0]-1]=l[1]
  print(sum(tmp))

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

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

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

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

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

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

Solution (Python):
def execute(n, tn, m, pxm):
    result = []
    for px in pxm:
        cp = tn[:]
        cp[px[0] - 1] = px[1]
        result.append(sum(cp))
    return result


if __name__ == '__main__':
    n = int(input())
    tn = list(map(int, input().split()))
    m = int(input())
    pxm = []
    for _ in range(m):
        p, x = map(int, input().split())
        pxm.append([p, x])
    result = execute(n, tn, m, pxm)
    print("\n".join(map(str, result)))

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())
    p -= 1
    print(s - t[p] + x)

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

M  = int(input())
PX = [input() for _ in range(M)]

for px in PX:
    P, X = map(int, px.split())
    print(S - T[P-1] + X)

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

M  = int(input())

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

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


m = int(input())
for i in range(m):
  p, x = map(int, input().split())
  
  ans = 0
  for j in range(n):
    ans += x if j == p-1 else list1[j]
  print(ans)

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

M = int(input())
for i in range(M):
    p, x = map(int, input().split())
    total = 0
    for j in range(N):
        total += x if j == p - 1 else times[j]
    print(total)

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    a,b = map(int,input().split())
    P.append(a)
    X.append(b)
for i in range(M):
    S = 0
    for j in range(N):
        if j==P[i]-1:
            S+=X[i]
        else:
            S+=T[j]
    print(S)

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

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

ans = []
for i in range(M):
    p, x = map(int, input().split())
    tmp = list(T)
    tmp[p-1] = x
    ans.append(sum(tmp))
for a in ans:
    print(a)

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

for _ in range(r):
  p, x = map(int, input().split())
  temp = copy.deepcopy(deftime)
  temp[p-1] = x
  print(sum(temp))

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

for _ in range(r):
  p, x = map(int, input().split())
  temp = copy.deepcopy(deftime)
  temp[p-1] = x
  print(sum(temp))

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 i in range(M):
    print(sum(T[: P[i] - 1]) + X[i] + sum(T[P[i]:]))

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

Solution (Python):
s=int(input())
a=list(map(int,input().split()))
b=int(input())
for i in range(b):
    c,d=map(int,input().split())
    print(sum(a[:c-1])+sum(a[c:])+d)

Solution (Python):
s=int(input())
a=list(map(int,input().split()))
b=int(input())
s=[]
for i in range(b):
    c,d=map(int,input().split())
    s.append(sum(a[:c-1])+sum(a[c:])+d)   
    print(s[i])

Solution (Python):
s=int(input())
a=list(map(int,input().split()))
b=int(input())
s=[]
for i in range(b):
    c,d=map(int,input().split())
    s.append(sum(a[:c-1])+sum(a[c:])+d)   
for i in range(b):
    print(s[i])

Solution (Python):
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
time=[]
for i in range(M):
    x=[int(j) for j in input().split()]
    time+=[sum(T)-T[x[0]-1]+x[1]]
for i in range(M):
    print(time[i])

Solution (Python):
n = int(input())
t = [int(x) for x in input().split()]
sum_t = sum(t)
sum_list = []

for i in range(int(input())):
    p, x = [int(x) for x in input().split()]
    sum_list.append(sum_t + x - t[p - 1])

for s in sum_list:
    print(s)

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

Solution (Python):

N = int(input())
T = [int(x) for x in input().split()]



M = int(input())

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

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

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

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

Solution (Python):
n=int(input())
t=[int(_) for _ in input().split()]
m=int(input())
p=[[int(j) for j in 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):
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
P=[0 for i in range(M)]
X=[0 for i in range(M)]
for i in range(M):
    P[i],X[i]=map(int,input().split())
    P[i]-=1
S=sum(T)
for i in range(M):
    print(S-T[P[i]]+X[i])

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





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





m = int(input())








cnt, ans, mx, mn = 0, 0, 0, 100000000
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())








cnt, ans, mx, mn = 0, 0, 0, 100000000
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())
P,X = [],[]
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

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

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

Solution (Python):
n = int(input())
T = list(map(int,input().split()))
total = sum(T)
m = int(input())
PX = [list(map(int,input().split())) for _ in range(m)]

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

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

for _ in range(M):
    i,j=map(int,input().split())
    print(SUM-T[i-1]+j)

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

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

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

Solution (Python):
n = int(input())
t_list = list(map(int, input().split()))
m = int(input())
px_dict = {}
for i in range(m):
    tmp_list = list(map(int, input().split()))
    print(sum(t_list) - t_list[tmp_list[0] - 1] + tmp_list[1])

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

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

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

Solution (Python):
N = int(input())
Ts = [int(x) for x in input().split()]
M = int(input())
for i in range(M):
    p,x = list(map(int,input().split()))
    time = 0
    for j in range(N):
        if j == (p-1):
            time += x
        else:
            time += Ts[j]
    print(time)

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)

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

Solution (Python):
int_n = int(input())
li_t = list(map(int, input().split()))
int_m = int(input())
li_p = list()
li_x = list()

for i in range(int_m):
    p, x = map(int, input().split())
    li_p.append(p)
    li_x.append(x)


for x, p in zip(li_p, li_x):
    w_li_t = li_t[:]
    w_li_t[x-1] = p

    print(sum(w_li_t))

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

t = input().split()
sum=0
for i in t:
    sum+=int(i)

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

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

temp = sum(T)

for i, (p, x) in enumerate(PX):
    ans = temp - T[p - 1] + x
    print(ans)

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

sumT = sum(Ts)
for P, X in PXs:
    print(sumT - Ts[P - 1] + X)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
for i in range(int(input())):
  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())
P = [0] * M
X = [0] * M
for i in range(M):
    P[i], X[i] = map(int, input().split())

T_original = tuple(T)
for j in range(M):
    T[P[j]-1] = X[j]
    print(sum(T))
    T = list(T_original)

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

  l.append(s-t[p-1]+x)
for i in l:
  print(i)

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())
T = input().rstrip().split(" ")
T = [int(i) for i in T]
M = int(input())
for i in range(M):
    To = T[:]
    temp = input().rstrip().split(" ")
    P = int(temp[0])
    X = int(temp[1])
    T[P-1] = X
    print(sum(T))
    T = To[:]

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 px:
  tClone = t[:]
  tClone[i[0] - 1] = i[1]
  print(sum(tClone))

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s+x-a[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())
T = list(map(int,input().split()))
M = int(input())

d = {}
for i in range(N):
  d[i+1] = T[i]

for i in range(M):
  P, X = map(int,input().split())
  cv = d[P]
  d[P] = X
  print(sum(d.values()))
  d[P] = cv

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 i in range(M):
	sum = 0
	for j in range(N):
		if j == (P[i] - 1):
			sum = sum + X[i]
		else:
			sum = sum + T[j]
	print(sum)

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())
    q = sum(t)-t[p-1]+x
    ans.append(q)
for i in range(m):
    print(ans[i])

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


if __name__ == '__main__':
    main()

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

c = []
for i in range(m):
    c.append([int(m) for m in input().split()])
k = sum(t)
for i in range(m):
    print(k - t[c[i][0] - 1] + c[i][1])

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

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

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

for t in range(m):
    print(ans[t])

Solution (Python):
N = int(input())
t_arr = list(map(int, input().split()))
total = sum(t_arr)
M = int(input())
ans_arr = []
for _ in range(M):
    p, x = map(int, input().split())
    ans_arr.append(total - t_arr[p-1] + x)
for m in range(M):
    print(ans_arr[m])

Solution (Python):
n = int(input())
t = []
sum = 0

line = input().split(" ")
for i in range(n):
    t.append(int(line[i]))
    sum += int(line[i])

m = int(input())
for i in range(m):
    line = input().split(" ")
    p = int(line[0]) - 1
    x = int(line[1])
    for j in range(len(t)):
        if j == p:
            comp = sum - t[j] + x
    print(comp)

Solution (Python):
n = int(input())
t = []
sum = 0
p = []
x = []

line = input().split(" ")
for i in range(n):
    t.append(int(line[i]))
    sum += int(line[i])

m = int(input())
for i in range(m):
    line = input().split(" ")
    p.append(int(line[0]) - 1)
    x.append(int(line[1]))

for i in range(m):
    for j in range(len(t)):
        if j == p[i]:
            comp = sum - t[j] + x[i]
    print(comp)

Solution (Python):
N = int(input())
time_list = [int(i) for i in input().split()]
M = int(input())
drinked_time_list = []
for i in range(M) :
    drinked_time_list.append([int(i) for i in input().split()])

base_total_time = sum(time_list)
for dr in drinked_time_list :
    base_time = time_list[dr[0]-1]
    print(base_total_time-base_time+dr[1])

Solution (Python):



def main():
    """Function."""
    n = int(input())
    t = list(map(int, input().split()))

    base = sum(t)

    m = int(input())
    for _ in range(m):
        num, rep = map(int, input().split())
        num = num - 1
        print(base - t[num] + rep)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import collections
import itertools
import math
import re
from collections import deque



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

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
    for j in range(n):
        if px[i][0] == j+1:
            ans += px[i][1]
        else:
            ans += t[j]
    print(ans)

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

Solution (Python):
n=int(input())
T=[0]+list(map(int,input().split()))
m=int(input())
PX=[list(map(int,input().split())) for i in range(m)]


for i,j in PX:
  tmp=T[:i]+[j]+T[i+1:]
  print(sum(tmp))

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

Solution (Python):
data_num=int(input())
data=input().split()

rdata_num=int(input())
for i in range(rdata_num):
  dict={}
  for i in range(data_num):
    dict[i]=int(data[i])

  list=[]
  p,x=input().split()   
  dict[int(p)-1]=int(x)
  
  for dict_val in dict.values():
    list.append(dict_val)

  print(sum(list))

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

S = sum(T)
for p, x in PX:
    print(S-T[p-1]+x)

Solution (Python):
from copy import deepcopy
n = input()
a = [int(x) for x in input().split()]
m = int(input())
for _ in range(m):
  t = deepcopy(a)
  b,c = [int(x) for x in input().split()]
  t[b-1] = c
  print(sum(t))

Solution (Python):
from copy import deepcopy
n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
for _ in range(m):
  t = deepcopy(a)
  b,c = [int(x) for x in input().split()]
  t[b-1] = c
  print(sum(t))

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

a=input().strip().split(" ")
a=[int(j) for j in a]

M=int(input())

for i in range(M):
    c=a[:]
    Sum=0
    b=input().strip().split(" ")
    b=[int(j) for j in b]
    c[b[0]-1]=b[1]
    for k in range(len(c)):
        Sum+=c[k]

    print(Sum)

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

Solution (Python):
def abc050_b():
    number_of_problem = int(input())
    time_to_solve_list = [int(i) for i in input().split()]
    sum_of_solve_list = sum(time_to_solve_list)
    
    variety_of_drinks = int(input())

    problem_vs_time = []

    for _ in range(variety_of_drinks):
        buf = list(map(int, input().split()))
        problem_num = buf[0] - 1
        time_to_solve = buf[1]

        problem_vs_time.append([problem_num, time_to_solve])

    for key, value in problem_vs_time:
        print(sum_of_solve_list + value - time_to_solve_list[key])


if __name__ == '__main__':
    abc050_b()

Solution (Python):
def abc050_b():
    number_of_problem = int(input())
    time_to_solve_list = [int(i) for i in input().split()]

    variety_of_drinks = int(input())

    problem_vs_time = []

    for _ in range(variety_of_drinks):
        buf = list(map(int, input().split()))
        problem_num = buf[0] - 1
        time_to_solve = buf[1]

        problem_vs_time.append([problem_num, time_to_solve])

    for key, value in problem_vs_time:
        buf = time_to_solve_list[key]
        time_to_solve_list[key] = value

        print(sum(time_to_solve_list))
        time_to_solve_list[key] = buf


if __name__ == '__main__':
    abc050_b()

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

for i in range(M):
    P, X = list(map(int, input().rstrip().split()))
    total = 0
    for j in range(len(T)):
        t = 0
        if j == P - 1:
            t = X
        else:
            t = T[j]

        total += t

    print(total)

Solution (Python):



def solve():
    _ = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    for _ in range(M):
        total = 0
        P, X = map(int, input().split())
        for index, time in enumerate(T):
            if index + 1 == P:
                total += X
            else:
                total += time

        print(total)


if __name__ == '__main__':
    solve()

Solution (Python):

_ = int(input())
li_T = list(map(int, input().split()))
s_T = sum(li_T)

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

Solution (Python):

_ = int(input())
li_T = list(map(int, input().split()))

for _ in range(int(input())):
    p, x = map(int, input().split())
    print(sum(li_T) - li_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)]
res = sum(t)
for (p,x) in px:
    print(res + x - t[p-1])

Solution (Python):

N = int(input())
li_T = list(map(int, input().split()))
M = int(input())

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

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