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

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

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
for i in range(M):
    Pi,Xi=map(int,input().split())
    a = T[Pi-1]
    T[Pi-1] = Xi
    b = 0
    for j in range(N):
        b = b + T[j]
    print(b)
    T[Pi-1] = a

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

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 j in range(len(drink)):
    P,X=drink[j]
    time=X+sum(T)-T[P-1]
    print(time)

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

Solution (Python):
N = int(input())
T = [int(TN) for TN in input().split()]
SumT = sum(T)
M = int(input())
PX = [[] for TM in range(0,M)]
for TM in range(0,M):
    PX[TM] = [int(TPX) for TPX in input().split()]
for TM in range(0,M):
    print(SumT-T[PX[TM][0]-1]+PX[TM][1])

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

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

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

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

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

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


def read():
    N = int(input().strip())
    T = list(map(int, input().strip().split()))
    M = int(input().strip())
    PX = []
    for i in range(M):
        p, x = map(int, input().strip().split())
        PX.append((p, x))
    return N, T, M, PX


def solve(N, T, M, PX):
    S = sum(T)
    for p, x in PX:
        ans = S - T[p-1] + x
        print(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):

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

A = []
for i in range(M):
    T_copy = T.copy()
    T_copy[P[i]-1] = X[i]
    A.append(sum(T_copy))    

for k in range(M):
    print(A[k])

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l=[0]+l
s=sum(l)
k=int(input())
for _ in range(k):
  m,n=map(int,input().split())
  print(s-l[m]+n)

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

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


result = sum(t)

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

Solution (Python):
import copy

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

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

M = int(input())
for i in range(M):
    Ml = list(map(int, input().split()))
    print(s + Ml[1] - Nl[Ml[0] - 1])

Solution (Python):




def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip())
    ts = [int(x) for x in input().rstrip().split(" ")]
    original_time = sum(ts)
    m = int(input().rstrip())
    for i in range(m):
        p, x = [int(x) for x in input().rstrip().split(" ")]
        print(original_time - ts[p-1] + x)

if __name__ == "__main__":
    resolve()

Solution (Python):

def main():
    import copy
    _ = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    px = [input().split() for i in range(m)]
    

    for i in range(m):
        tt = copy.copy(t)
        tt[int(px[i][0])-1] = int(px[i][1])
        print(sum(tt)) 


if __name__ ==  "__main__":
    main()

Solution (Python):
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0

for j in new:
  sum += int(j)

  
num_drinks = int(input())
for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if int(new_line[1]) != int(new[int(new_line[0])-1]):
    temp = sum - int(new[int(new_line[0])-1]) + int(new_line[1])
    print(temp)
  else:
    print(sum)

Solution (Python):
num_problems = input()
a = input()
total = 0
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)

Solution (Python):
ProNum = int(input())
time = input()
time = (time.split())
TotalTime = 0

for t in time:
  TotalTime += int(t)
                  
DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time[int(line[0])-1])
  print(TotalTime+diff)

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

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

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

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

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

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

tot_t = sum(t)

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

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)]
time=sum(t)
for i in range(m):
    print(time-t[px[i][0]-1]+px[i][1])

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)]
a,b = [list(i) for i in zip(*l)]
for i in range(m):
    s = list(t)
    j = a[i] - 1
    s[j] = b[i]
    print(sum(s))

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

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

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

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

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.insert(0, 0)

for PX in PX:
    ans = T[:]
    ans[PX[0]] = PX[1]
    print(sum(ans))

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

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

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

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

for h in range(m):
    s = 0
    for j in range(n):
        if j == px[h][0]:
            s += px[h][1]
        else:
            s += t[j]
    print(s)

Solution (Python):
N = int(input())
T = list(map(lambda t: int(t), input().split(" ")))
M = int(input())
P = []
T_new = []
T_diff = []
for i in range(M):
  tmp = input().split(" ")
  P.append(int(tmp[0]) - 1)
  T_new.append(int(tmp[1]))
  T_diff.append(T_new[i] - T[P[i]])

T_sum = sum(T)
print("\n".join([str(T_sum + t_d) for t_d in T_diff]))

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

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

m = int(input())

drink_num_time = []
drink_time = []

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

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[(drink_num_time[i][0])-1])

for i in range(m):
    print(drink_time[i])

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
T = inintl()
m = inint()

for i in range(m):
    p, x = inintm()
    t = T[p-1]
    T[p-1] = x
    print(sum(T))
    T[p-1] = t

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

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
sum_ = sum(T)
M = int(input())
ans = list()
for i in range(M) :
    P, X = map(int,input().split())
    gap = T[P-1] - X
    ans.append(sum_ - gap)

for i in range(len(ans)):
    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)]
sumt = sum(t)
for i in range(m):
    print(sumt - t[px[i][0]-1] +px[i][1])

Solution (Python):
n=int(input())
t=list(map(int, input().strip().split()))
m=int(input())
px = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    px.append(array)
wa=0
for i in range(n):
    wa+=t[i]

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

M = int(input())

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

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

Solution (Python):
n = int(input())
t_list = [int(x) for x in input().split()]
t_sum = sum(t_list)
m = int(input())
for _ in range(m):
    p, x = [int(x) for x in input().split()]
    print(t_sum - t_list[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):
    ans = 0
    for j in range(n):
        if (drink[i][0] - 1 == j):
            ans += drink[i][1]
        else:
            ans += t[j]
    print(ans)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

for an in ans:
    print(an)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
ans=[]
s=sum(t)
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    ans.append(s-t[p-1]+x)
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 _ in range(M)]


for i in range(M):
    cnt = 0
    for j in range(len(T)):
        if px[i][0] == j+1 :
            cnt += px[i][1]
        else:
            cnt += T[j]
    print(cnt)

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

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):
    ans = sum(T) + P[i][1] - T[P[i][0]-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)]

tsum = sum(T)

for px in PX:
    p = px[0]
    x = px[1]

    t = tsum - T[p - 1] + x
    print(t)

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

Solution (Python):
N = int(input())
lsT = list(map(int,input().split()))
M = int(input())
sum1 = sum(lsT)
lsP = []
for i in range(M):
    lsP.append(list(map(int,input().split())))

for i in range(M):
    print(sum1-lsT[lsP[i][0]-1]+lsP[i][1])

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

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

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-T[P-1]+X)

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

sum_t = sum(t)

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

for v in res:
    print(v)

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

Ans = []

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

for ans in Ans:
    print(ans)

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

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

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

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

pxn = []
for _ in range(m):
  p, x = map(int, input().split())
  pxn.append([p, x])
  
for p in pxn:
  print(sum(tn) - tn[p[0]-1] + p[1])

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

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












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

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
T = readInts()
sumT = sum(T)
p_ = I()
for i in range(p_):
    p,x = readInts()
    print(sumT - 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)-T[P-1]+X)

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

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())
    p -= 1
    PX.append((p, x))

S = sum(T)
for i in range(m):
    p, x = PX[i]
    ans = S - T[p] + x
    print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
T = inl()
M = ini()


def solve():
    tsum = sum(T)
    for i in range(M):
        p, x = inm()
        p -= 1
        ans = tsum - T[p] + x
        print(ans)


solve()

Solution (Python):
def solve():
  N = int(input())
  T = list(map(int, input().split()))
  M = int(input())
  ans = [sum(T)]*M
  for i in range(M):
    x,y = map(int, input().split())
    ans[i] += y-T[x-1]
  return ans
print(*solve(),sep='\n')

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

ans = sum(t)
for p,x in px:
    a = ans-t[p-1]+x
    print(a)

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

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

Solution (Python):

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

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

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

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

for i in range(M):
    a,b=map(int,input().split())
    SS=S-T[a-1]+b
    print(SS)

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

times = list(map(int, input().split(' ')))

summary = sum(times)

m = int(input())

for i in range(m):
    p, x = map(int, input().split(' '))
    print(summary - (times[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[:p-1])+x+sum(t[p:]))

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

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
m=int(input())
d=0
for i in range(0,len(a)):
        d=d+a[i]
for i in range(m):
    b,c=[int(i) for i in input().split()]
    z=a[b-1]
    e=(d-(z))+(c)
    print(e)

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):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    T = list(map(int, readline().split()))
    M, *PX = map(int, read().split())

    s = sum(T)
    ans = [0] * M
    for i, (p, x) in enumerate(zip(*[iter(PX)] * 2)):
        p -= 1
        ans[i] = s + (x - T[p])

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

    return


if __name__ == '__main__':
    main()

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

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

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

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

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

M = int(input())

dic ={}
base = sum(T)

for i in range(M):
  a,b = map(int,input().split())
  print(base - T[a-1]+b)

Solution (Python):
a=int(input())
List1 = list(map(int, input().split()))
Row = int(input())
List2 = []
for i in range (Row):
  List2.append(list(map(int, input().split())))
res = [0]*Row
for i in range(Row):
  for j in range(a):
    if j+1 == List2[i][0]:
      res[i] += List2[i][1]
    else:
      res[i] += List1[j]
for element in res:
  print(element)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    T = LI()
    M = I()
    PX = [LI() for _ in range(M)]

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

if __name__ == '__main__':
    resolve()

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 - T[p-1] + x)

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

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

t = sum(T)

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

Solution (Python):
n,tt,m,*px = [list(map(int, s.split())) for s in open(0)]

stt = sum(tt)

for p,x in px:
    print(stt-tt[p-1]+x)

Solution (Python):
import copy

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

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

Solution (Python):
import copy

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

m = int(input())
for i in range(m):
    tmp = copy.deepcopy(lis)
    a, b = map(int, input().split())
    tmp[a-1] = b
    print(sum(tmp))

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

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

Solution (Python):
import copy
N = int(input())
MM = input().split()
M = int(input())
for i in range(M):
  cc = copy.copy(MM)
  total = 0
  
  aa = input().split()
  a = int(aa[0])
  b = int(aa[1])
  cc[a-1] = b
  for j in cc:
    total += int(j)
  print(total)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
time = [0] * m
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()))
m=int(input())
d=[]
for _ in range(m):
  d.append(list(map(int,input().split())))
  
ans=[sum(t)-t[x[0]-1]+x[1] for x in d]
for x in ans:
  print(x)

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

Solution (Python):
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    ans = []
    for _ in range(M):
        P, X = map(int, input().split())
        ans.append(str(sum(T) - T[P - 1] + X))
    print("\n".join(ans))


if __name__ == '__main__':
    main()

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

questions = []
copy = []
answer = 0

x = input().split()

for num in range(len(x)):
    questions.append(x[num])
    copy.append(x[num])

v = input()
m = int(v)

for num in range(m):
    d = input().split()
    questions[int(d[0]) - 1] = int(d[1])
    for y in range(len(questions)):
        answer += int(questions[y])
    print(answer)
    answer = 0
    for z in range(len(questions)):
        questions[z] = copy[z]

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

Solution (Python):
import copy

n = int(input())
t = list(map(int, input().split()))
m = int(input())
dorink = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):
    t_copy = copy.deepcopy(t)
    t_copy[dorink[i][0] - 1] = dorink[i][1]
    print(sum(t_copy))