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

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

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

for drink in drinks:
    time = 0
    copy = times.copy()
    copy[drink[0]-1] = drink[1]
    for i in copy:
        time += i
    print(time)

Solution (Python):

N = int(input())

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


M = int(input())

X = []


for i in range(M):
    X.append(list(map(int,input().split())))
    X[i][0] = X[i][0]-1

Y = []

for i in range(N):
    Y.append(T[i])
    
for i in range(len(X)):
    Y_copy = Y.copy()
    Y_copy[X[i][0]] = X[i][1]
    print(sum(Y_copy))

Solution (Python):

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

Solution (Python):
N = int(input())
T_s = list(map(int,input().split()))
M = int(input())
PX_s = [list(map(int,input().split())) for _ in range(M)]
SUM = sum(T_s)
for P,X in PX_s:
    print(SUM - (T_s[P-1] - X))

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

sum_T = sum(T)

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

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

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

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

i = 0
for x[i] in x:
    l = list(t)
    j = x[i][0] - 1 
    k = x[i][1]     
    i += i
    l[j] = k
    print(sum(l))

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

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

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

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

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

for drink in drinks:
    total = 0
    for j in range(N):
        if drink[0] == j+1:
            total += drink[1]
        else:
            total += times[j]
    print(total)

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

Solution (Python):
from typing import List


def answer(n: int, t: List[int], m: int, pxs: List[List[int]]) -> str:
    result = []
    for px in pxs:
        t_copy = t.copy()
        t_copy[px[0] - 1] = px[1]
        result.append(str(sum(t_copy)))

    return '\n'.join(result)


def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    pxs = [list(map(int, input().split())) for _ in range(m)]
    print(answer(n, t, m, pxs))


if __name__ == '__main__':
    main()

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

def ans050(N:int, T:str, M:int, P:list):
    T_list=list(map(int,T.split()))
    ans_list=[]
    for i in range(M):
        T_list = list(map(int, T.split()))
        P_list=list(map(int,P[i].split()))
        del T_list[P_list[0]-1]
        T_list.append(P_list[1])
        ans_list .append(sum(T_list))
    return ans_list
for i in range(M):
    print((ans050(N,T,M,P))[i])

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

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

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

Solution (Python):

import sys
input=sys.stdin.readline
import copy

def main():
    questions=[]
    dp=[]
    n = int(input())
    questions=list(map(int,input().split()))
    m = int(input())
    drinks=[list(map(int,input().split())) for _ in range(m)]
    for drink in drinks:
        dp=copy.deepcopy(questions)
        dp[drink[0]-1]=drink[1]
        print(sum(dp))
    
if __name__=="__main__":
    main()

Solution (Python):
quiznum=int(input())
timeline=input().split(" ")
timeline=[int(n) for n in timeline]

time_0=0
for i in range(quiznum):
    time_0+=timeline[i]


medinum=int(input())
for i in range(medinum):
    temp_line=input().split(" ")
    a=int(temp_line[0])
    b=int(temp_line[1])
    time=time_0 - timeline[a-1] + b
    print(time)

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

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

for a in ans:
    print(a)

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

for i in range(N):
   T[i] = int(T[i])

S = sum(T)

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

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

t_sum = sum(T)

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

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

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

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

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


for i in range(m):
    sum = 0
    b = int(data_2[i][0]) - 1
    a = data_1[b]
    data_1[b] = int(data_2[i][1])
    for j in range(n):
        sum += data_1[j]
    print(sum)
    data_1[b] = a

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

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

for _ in range(m):
  A = copy.copy(T)
  a,b = map(int,input().split())
  A[a-1] = b
  print(sum(A))

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

Solution (Python):
def main():
    n = int(input())
    times = list(map(int, input().split(' ')))
    n = int(input())
    drinks = [list(map(int, input().split(' '))) for _ in range(n)]
    all_time = sum(times)
    for drink in drinks:
        print(all_time - (times[drink[0]-1] - drink[1]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
t = [0] + list(map(int, input().split()))
m = int(input())

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

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

for i in range(M):
    sum_num = 0
    for j in range(N):
        if L[i][0] - 1 == j:
            sum_num += L[i][1]
        else:
            sum_num += T[j]
    print(sum_num)

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):
    updated_T = T[:]
    updated_T[P[i][0] - 1] = P[i][1]

    print(sum(updated_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)

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

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
ans = sum(T)
M = int(input())
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())
x=sum(T)
for _ in range(M):
    P,X=map(int,input().split())
    print(x+X-T[P-1])

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

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

for i in range(M):
    t_sum = X[i]
    for j in range(N):
        if j == P[i] - 1:
            continue
        t_sum += T[j]
    print(t_sum)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    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]))


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    n = int(input())
    t_list = list(map(int, input().split()))
    m = int(input())
    total_time = sum(t_list)

    for _ in range(m):
        p, x = map(int, input().split())
        diff = t_list[p - 1] - x
        print(total_time - diff)


if __name__ == "__main__":
    main()

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

for i in range(c):
  f=b.copy()
  p=d[i][0]-1
  f[p]=d[i][1]
  print(sum(f))

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)]
ans = []
for num in p:
    print(sum(t) - t[num[0]-1] + num[1])

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
L = []
res = []
for i in range(M):
    P, X = map(int, input().split())
    buf = []
    for j in range(len(T)):
        if P == j+1:
            buf.append(X)
        else:
            buf.append(T[j])
    res.append(sum(buf))

for i in res:
    print(i)

Solution (Python):
n = int(input())
t_l = list(map(int, input().split()))
m = int(input())
import copy
for _ in range(m):
    k, v = map(int, input().split())
    tmp_t = copy.deepcopy(t_l)
    tmp_t[k-1] = v
    print(sum(tmp_t))

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)]
tmp=0
ans=0

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

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


res_time = sum(timeList)

for a in argList:

    
    print(res_time - timeList[a[0]-1] + a[1])

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())
    T = sum(t) - t[a-1] + b
    print(T)

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

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
t = rl()
sum_ = sum(t)
m = ri()
for _ in range(m):
    p, x = rm()
    p -= 1
    print(sum_ - t[p] + x)

Solution (Python):
def solve():
    N = int(input())
    T = [int(i) for i in input().split()]
    M = int(input())
    t = sum(T)
    for i in range(M):
        P, X = [int(x) for x in input().split()]
        print(t - T[P - 1] + X)

if __name__ == "__main__":
    solve()

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

sum_l=sum(l)

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    S = sum(T)

    for i in range(M):
        p, x = map(int, readline().split())
        p -= 1

        print(S - T[p] + x)


if __name__ == '__main__':
    main()

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

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

sum_T = sum(T)
for i in range(m):
    print(sum_T - T[D[i][0] - 1] + D[i][1])

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

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

summ = sum(t)

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

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

summ = sum(t)

for _ in range(int(input())):
    p, x = map(int, input().split())
    print(summ + x-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())
    Y = T[P-1]
    T[P-1] = X
    print(sum(T))
    T[P-1] = Y

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

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

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

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

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

Solution (Python):
input();t=[*map(int,input().split())];T=sum(t)
print(*[T-t[i-1]+j for i,j in [[*map(int,input().split())] for _ in range(int(input()))]],sep='\n')

Solution (Python):
input();t=list(map(int,input().split()));T=sum(t)
print(*[T-t[i-1]+j for i,j in [list(map(int,input().split())) for _ in range(int(input()))]],sep='\n')

Solution (Python):
n,t=int(input()),list(map(int,input().split()));T=sum(t)
print(*[T-t[i-1]+j for i,j in [list(map(int,input().split())) for _ in range(int(input()))]],sep='\n')

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

temp = sum(t)

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

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

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

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

time_sum_raw = sum(times)
for pi, xi in drinks:
    print(time_sum_raw - times[pi - 1] + xi)

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

time_lst = []
for i in range(m):
    problem = px_lst[i][0] - 1
    time = px_lst[i][1]
    before = t_lst[problem]
    t_lst[problem] = time
    time_lst.append(sum(t_lst))
    t_lst[problem] = before

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

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())
  ans = sumT-T[P-1]+X
  print(ans)

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

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

Solution (Python):
import copy

def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    PX = []
    for i in range(M):
        P, X = map(int, input().split())
        tmp = copy.copy(T)
        tmp[P-1] = X
        print(sum(tmp))

if __name__ == "__main__":
    main()

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())
a = list(map(int, input().split()))
num_drink = int(input())

for i in range(num_drink):
    P,X = map(int,input().split())
    A = a.copy()
    A[P-1] = X
    print(sum(A))

Solution (Python):
num_problems = int(input())
t = [int(n) for n in input().split()]
total = sum(t)
num_drinks = int(input())

for i in range(num_drinks):
  m_id, m_val = [int(n) for n in input().split()]
  ans = total - t[m_id-1] + m_val
  print(ans)

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

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

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

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

Solution (Python):
import copy
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):
    A=copy.copy(T)
    A[PX[i][0]-1]=PX[i][1]
    print(sum(A))

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    drink = []
    for _ in range(M):
        p, x = map(int, input().split())
        drink.append((p, x))

    sum_time = sum(T)
    for i in range(M):
        p, x = drink[i]
        p -= 1
        print(sum_time - (T[p] - x))



if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

from queue import Queue,PriorityQueue

from string import ascii_lowercase


sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)


def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)

                


def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
            
    
def solve():
    n=inp()
    l=li()
    s=sum(l)
    d={i+1:l[i] for i in range(n)}
    m=inp()
    for i in range(m):
        x=s
        a,b=mp()
        x-=d[a]
        x+=b
        pr(x)


for _ in range(1):
    solve()

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

sumTime = sum(T)

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

data = l()

su = sum(data)

po = onem()

for i in range(po):
    a,b = m()
    a -= 1
    print(su + b - data[a])

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array





sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


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

    N = ii()
    T = il()
    M = ii()
    sm = sum(T)

    for m in range(M):
        P, X = il()
        print(sm-(T[P-1]-X))


if __name__ == '__main__':
    main()