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()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    sum_t = sum(T)
    idx = PX[i][0] - 1
    if T[idx] >= PX[i][1]:
        sum_t -= (T[idx] - PX[i][1])
    else:
        sum_t += PX[i][1] - T[idx]
    print(sum_t)

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())
time = sum(T)

for i in range(M):
    P, X = map(int, input().split())
    print(time - 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())

time = sum(T)

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

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

Solution (Python):
import copy

N=int(input())

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

M=int(input())

for m in range(M):
  time2=copy.copy(time)
  p,x=map(int,input().split())
  time2[p-1]=x
  ans=sum(time2)
  print(ans)

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

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

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)

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

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

for i in range(int(input())):
    P, X = map(int, input().split())
    t = 0
    
    for j in range(N):
        if j+1 == P: t += X
        else: t += T[j]
    
    print(t)

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())
    t = T[P-1]
    T[P-1] = X
    print(sum(T))
    T[P-1] = t

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

for P, X in drinks:
  result = 0
  for i in range(N):
    if i == (P-1):
      result += X
    else:
      result += T[i]
  print(result)

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

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

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

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

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

for p, m in pm:
    ans = 0
    for i in range(len(t)):
        if p-1 == i:
            ans += m
        else:
            ans += t[i]
    print(ans)

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())
px = []
for _ in range(m):
    p, x = map(int, input().split())
    px.append([p-1, x])

for i in px:
    ind = i[0]
    print(sum(t[:ind] + [i[1]] + t[ind+1:]))

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

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

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

for i in range(m):
    p, x = (int(x) for x in 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):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    sa = t[p[i] - 1] - x[i]
    print(sum_t-sa)

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

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 = sum(T)

for i in range(M):
    p,x = PX[i]
    print(SUM - T[p-1] + x)

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

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 = sum(T) - T[p - 1] + x
    print(S)

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


if __name__ == "__main__":
    resolve()

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

t_list = [int(i) for i in input().split()]
t_sum = sum(t_list)

m = int(input())

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

Solution (Python):
n1 = int(input())
li = list(map(int,input().split()))
n2 = int(input())
for i in range(n2):
    p,x = map(int,input().split())
    a = li[p-1]
    li[p-1] = x
    print(sum(li))
    li[p-1] = a

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

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)]

unused = sum(T)

for PX in PX_list:
    print(unused - T[PX[0] - 1] + PX[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)]

ans = sum(t)
for i in range(M):
  p,x = px[i]
  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())
    ans += sum(T[0:P-1])
    ans += X
    ans += sum(T[P:len(T)])
    print(ans)
    ans = 0

Solution (Python):


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

t_sum = sum(t)

for p, x in px:
    ans = t_sum - t[p-1] + x
    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)]

su = sum(T)
for i in range(m):
    print(su - T[P[i][0]-1] + P[i][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):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    t = list(map(int, input().split()))
    M = int(input())
    px = [list(map(int, input().split())) for i in range(M)]

    sum_ = sum(t)

    for i in range(M):
        p, x = px[i]
        print(sum_ - (t[p-1] - x))


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PT = [list(map(int,input().split())) for i in range(M)]
ans = [0]*M
for i in range(M):
    for j in range(N):
        if PT[i][0]==j+1:
            ans[i]+=PT[i][1]
        else: ans[i]+=T[j]
for i in range(M):
    print(ans[i])

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)]


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

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

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

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

Solution (Python):
n = int(input())
t = [int(time) for time in input().split()]
m = int(input())
for p, x in [map(int, input().split()) for _ in range(m)]:
    print(sum(t[i] if i != p - 1 else x for i in range(n)))

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

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
copy_t = t.copy()
m = int(input())
ans = 0
p = []
x = []
for i in range(0,m):
    input_p, input_x = map(int, input().split())
    p.append(input_p)
    x.append(input_x)
for z in range(m):
    for i in range(n):
        if p[z] == i+1:
            ans += x[z]
        else:
            ans += t[i]
    print(ans)
    ans = 0

Solution (Python):



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





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

Solution (Python):
N = int(input())
TList = list(map(int,input().split()))
Sum = sum(TList)

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

for i in range(M):
    problem = Data[i][0]
    diff = - TList[problem-1] + Data[i][1]
    print( Sum + diff)

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

total_t = sum(t)

for v in drinks:
    print(total_t - t[v[0] - 1] + v[1])

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

time =0

for x in m:
  time += x
d_num = int(input())
for i in range(d_num):
  drink = list(map(int, input().split()))
  print(time - (m[drink[0]-1]-drink[1]))

Solution (Python):
num = int(input())
list1 = list(map(int,input().split()))
time = 0
for ele in list1:
    time += ele
dnum = int(input())
for i in range(dnum):
    drink = list(map(int,input().split()))
    print(time - (list1[drink[0]-1]-drink[1]))

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

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

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

Solution (Python):
N = int(input())
matrix = []

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 sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
T = ILI()
M = II()
PX = [list(ISI()) for _ in range(M)]
for i in range(M):
    tmp = T[PX[i][0]-1]
    T[PX[i][0]-1] = PX[i][1]
    print(sum(T))
    T[PX[i][0]-1] = tmp

Solution (Python):

n = int(input())

t = input().split()

m = int(input())

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

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

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

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

Solution (Python):
import sys


stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


n = ni()
ttt = na()
s = sum(ttt)
m = ni()
for i in range(m):
    p, x = na()
    p -= 1
    print(s - ttt[p] + 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,x = (int(i) for i in input().split())
    P.append(p)
    X.append(x)

add = 0
for i in T:
    add += i

for i in range(M):
    ans = add
    Y = T[P[i]-1] - X[i]
    ans = ans - Y
    print(ans)

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):
  print(sum(t) + 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())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    p, x = PX[i]
    print(sumT-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):
  ans=0
  for j in range(n):
    if j==PX[i][0]-1:
      ans+=PX[i][1]
    else:
      ans+=T[j]
  print(ans)

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


if __name__ == "__main__":
    test()

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

M=int(input())

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

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

M=int(input())

for i in range(M):
    P,X=map(int,input().split())
    print(SUM-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())))
s = sum(T)
for i in range(M):
    print(s-T[PX[i][0]-1]+PX[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)]
total = sum(T)
for i in range(M):
    print(total-T[d[i][0]-1]+d[i][1])

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

Solution (Python):
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    drinks = []
    for _ in range(M):
        p, x = map(int, input().split())
        drinks.append([p, x])
    tot = sum(T)
    for i in range(M):
        p,x = drinks[i]
        d = T[p-1] - x
        print(tot - d)

if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
T=tuple(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())
a = list(map(int, input().split()))
m = int(input())

for i in range(m):
    p, x = map(int, input().split())
    b = a[:]
    b[p - 1] = x
    print(sum(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())
    print(sum(t) - 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 = [int(w) for w in input().split()]
    ans = sum(T) - T[P[0]-1] + P[1]
    print(ans)

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 px in PX:
  p=px[0]
  x=px[1]
  Total=sum(T)
  Total-=T[p-1]-x
  print(Total)

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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



for i in range(M):
    ans = sum(T)
    p = P[i]
    x = X[i]
    ans -= (T[p]-x)

    print(ans)

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

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

Solution (Python):
def main():
    n = int(input())
    t = [int(i) for i in input().split()]
    t_sum = sum(t)
    m = int(input())
    for j in range(m):
        p,x = (int(i) for i in input().split())
        ans = t_sum - t[p-1] + x
        print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    t = [int(i) for i in input().split()]
    m = int(input())
    for j in range(m):
        p,x = (int(i) for i in input().split())
        ans = 0
        for i in range(n):
            if i == p-1:
                ans += x
            else:
                ans += t[i]
        print(ans)
if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
t1=[int(_) for _ in input().split()]
m=int(input())
t2=[]
for i in range(m):
    s=input().split()
    t2.append(sum(t1)-t1[int(s[0])-1]+int(s[1]))
for i in range(m):
    print(t2[i])

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

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

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

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

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

Solution (Python):
n = int(input())
t = tuple(map(int,input().split()))
m = int(input())
st = sum(t)
for i in range(m):
  p,x = map(int,input().split())
  print(st - 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())
  print (sum(T[:p-1]) + sum(T[p:]) + x)

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

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()))
t_sum = sum(T)
M = int(input())
px = [list(map(int,input().split())) for _ in range(M)]
for p in px:
    ans = t_sum - T[p[0]-1] + p[1]
    print(ans)

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())
PX = []
for i in range(m):
  PX.append(list(map(int, input().split())))
for i in range(len(PX)):
  print(sum(T)+PX[i][1]-T[PX[i][0]-1])

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    T = inputList()
    
    M = inputInt()
    px = []
    for i in range(M):
        p,x = inputMap()
        px.append((p,x))
        
    ans = []
    for i,val in enumerate(px):
        tmp = 0
        p,x = val
        for j,vol in enumerate(T):
            if j == p-1:
                tmp += x
            else:
                tmp += vol
        ans.append(tmp)
        
    for i in ans:
        print(i)
    
if __name__ == "__main__":
	main()

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

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_time = sum(T)
abs_diff = 0
for i in range(M):
    index = P[i] - 1
    tmp_diff = X[i] - T[index]
    print(total_time + tmp_diff)

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

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

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
s = sum(t)
for i 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)]
old=sum(t)
for i in range(m):
  d=t[px[i][0]-1]-px[i][1]
  print(old-d)

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

for _ in range(M):
    p, x = list(map(int, input().split()))
    tmp = copy.deepcopy(T)
    tmp[p] = x
    print(sum(tmp))

Solution (Python):
def main():
    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())
    sumt = sum(t)
    for i in range(m):
        print(sumt - t[p[i] - 1] + x[i])


if __name__ == '__main__':
    main()

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

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

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

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

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

s = sum(T)
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())
pl = []
for i in range(m):
    pl.append(list(map(int, input().split())))


for i in pl:
    tt = t.copy()
    tt[i[0]-1] = i[1]
    print(sum(tt))

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

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

sum_t=sum(T)
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())

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

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

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

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

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):
from sys import stdin
import copy
N = int(stdin.readline())
time = [int(i) for i in stdin.readline().rstrip().split()]
M = int(stdin.readline())

for m in range(M):
    time_drink = copy.copy(time)
    P, X = [int(i) for i in stdin.readline().rstrip().split()]
    time_drink[P-1] = X
    print(sum(time_drink))

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

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



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

Solution (Python):
import sys
input=sys.stdin.readline

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

s = sum(T)
for i 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())
p_x = []
for i in range(m):
    p_x.append(list(map(int, input().split())))
for i in range(m):
    t_sub = t.copy()
    t_sub[p_x[i][0]-1] = p_x[i][1]
    print(sum(t_sub))

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

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


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

for i in range(m):
  drink.append(list(map(int, input().split())))
  
total = sum(times)

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

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

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

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

PX = []

for _ in range(M):
    p, x = map(int, input().split())
    PX.append((p, x))

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

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

original_sum = sum(Ts)

for p, x in PX_list:
  print(original_sum - Ts[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)
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(' ')))
SUM = sum(T)
M = int(input())

for i in range(0,M):
  x,y = map(int,input().split(' '))
  print(SUM -T[x-1] + y)

Solution (Python):

num_of_pro = raw_input()
problems = raw_input()
num_of_drinks = raw_input()
drinks_lines = []
count = 0 
while count < int(num_of_drinks):
	count += 1
	each_line = raw_input()
	drinks_lines.append(each_line)
for each_line in drinks_lines:
	problem_num = [int(each_num) for each_num in problems.split()]
	problem_num[int(each_line.split()[0]) -1] = int(each_line.split()[1])
	print sum(problem_num)

Solution (Python):
def main():
    n=int(input())
    t = list(map(int,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())
    
    for i in range(m):
        ans=sum(t)
        ans=ans+x[i]-t[p[i]-1]
        print(ans)
        
main()

Solution (Python):
N = int(input())
p_list = list(map(int,input().split()))
ans_list=[]
M = int(input())
for _ in range(M):
  ite,mount=map(int,input().split())
  temp_p = p_list.copy()
  temp_p[ite-1]=mount
  print(sum(temp_p))