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

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

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

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

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


if __name__ == '__main__':
	main()

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

Ts = list(map(int,input().split()))
M = int(input())

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

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

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

    return n, tlist, drinks


def submit():
    n, tlist, drinks = read_input()

    original_time = sum(tlist)

    for drink in drinks:
        diff = tlist[drink[0] - 1] - drink[1]
        print(original_time - diff)



if __name__ == '__main__':
    submit()

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

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

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

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

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

Solution (Python):

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


sm=sum(tl)

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

  
  a=X-tl[P-1]

  
  al.append(sm+a)


for x in al:
  print(x)

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

Solution (Python):


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

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

Solution (Python):
import copy

n = int(input())
T=list(map(int,input().split()))
m = int(input())
ans = []

for i in range(m):
    S = copy.copy(T)
    a,b = map(int, input().split())
    S[a-1] = b
    ans.append(sum(S))

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

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

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

t=[]

line=(input().split())

for i in range(n):
    t.append(int(line[i]))

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

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

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

Solution (Python):

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

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

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

for p, x in px:
    print(sumt - t[p-1] + x)

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

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

Solution (Python):
_ = input()
ts = [int(i) for i in input().split(" ")]
m = int(input())
res = []
sumres = sum(ts)
for i in range(m):
    p, x = [int(i) for i in input().split(" ")]
    res.append(sumres - ts[p-1] + x)

for i in res:
    print(i)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    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())
        print(total - T[P-1] + X)
    

if __name__ == '__main__':
    main()

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

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

Solution (Python):
lt = int(input())
times = [int(i) for i in input().split(' ')]
ld = int(input())
for drink in range(0, ld):
  i, t = [int(j) for j in input().split(' ')]
  i -= 1
  tmp = times[i]
  times[i] = t
  print(sum(times))
  times[i] = tmp

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

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

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

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

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

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

Solution (Python):
def main():
    N = input()
    T = [ int(ele) for ele in raw_input().split() ]
    M = input()
    P = [0]*M
    X = [0]*M

    for ele in xrange(M):
        P[ele], X[ele] = map(int, raw_input().split())
    
    base_time = sum(T)

    for i in xrange(M):
        after_drank = base_time - T[P[i]-1] + X[i]
        print(after_drank)

if __name__ == '__main__':
    main()

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

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

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

    print(s - T[P-1] + X)

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

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

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

Solution (Python):


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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
T = LIST()
M = INT()
PX = [LIST() for _ in range(M)]

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

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

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

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

L = []
for i in range(M):
    p,x = map(int, input().split())
    L.append((p,x))
    
T_sum = sum(T)
for i in L:
    check = T[i[0]-1] - i[1]
    print(T_sum - check)

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

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

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

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

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

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

for drink in drinks:
    diff = T[drink[0]-1] - drink[1] 
    print(sum(T)-diff)

Solution (Python):
n = int(input())
T = [int(t) for t in input().split()]
m = int(input()) 
drinks = []
diffs = [0 for _ in range(n)] 

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

for drink in drinks:
    diff = T[drink[0]-1] - drink[1] 
    print(sum(T)-diff)

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

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

Solution (Python):
I = lambda:map(int, input().split())
N = int(input())
T = list(I())
M = int(input())
ans = [sum(T)]*M
for i in range(M):
    p, x = I()
    ans[i] = ans[i] - T[p-1] + x
print('\n'.join(map(str, ans)))

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

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

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

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

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

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

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

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())
ans = []

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

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

Solution (Python):
def contest_with_drinks_easy(N: int, T: list, M: int, drinks: list)->list:
    total = sum(T)
    return [total - T[p-1] + m for p, m in drinks]


if __name__ == "__main__":
    N = int(input())
    T = [int(s) for s in input().split()]
    M = int(input())
    drinks = [tuple(int(s) for s in input().split()) for _ in range(M)]
    ans = contest_with_drinks_easy(N, T, M, drinks)
    print('\n'.join(map(str, ans)))

Solution (Python):
from functools import reduce
import copy

def main():
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input().rstrip())
    T = list(int(_) for _ in input().split())
    M = int(input().rstrip())
    A = []
    for i in range(M):
        tmp_T = copy.copy(T)
        sum = 0
        p, x = (int(_) for _ in input().split())
        tmp_T[p-1] = x
        for j in tmp_T:
            sum+= j
        A.append(str(sum))
    print('\n'.join(A))
    
if __name__ == '__main__':
    main()

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

all_time = sum(t)

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

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

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

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())
a = [int(x) for x in input().split()]
M = int(input())

for i in range(M):
    x,y = map(int,input().split())
    c = a[x-1]
    a[x-1] = y

    print(sum(a))
    a[x-1] = c

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

res = []

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

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

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
print(eval(input()))
"""

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

"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in d.items():
    if i[0] != 0 and i[1] == 1:
        print(0)
        quit()
    elif i[1] > 2:
        print(0)
        quit()
print(pow(2,n//2,mod))
"""

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

Solution (Python):

import sys


def solve(N: int, T: "List[int]", M: int, P: "List[int]", X: "List[int]"):
    ans = []
    ttl = sum(T)
    for i in range(M):
        ans.append(ttl-T[P[i]-1]+X[i])

    for i in ans:
        print(i)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    T = [ int(next(tokens)) for _ in range(N) ]  
    M = int(next(tokens))  
    P = [int()] * (M)  
    X = [int()] * (M)  
    for i in range(M):
        P[i] = int(next(tokens))
        X[i] = int(next(tokens))
    solve(N, T, M, P, X)

if __name__ == '__main__':
    main()

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

Solution (Python):

import copy
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):
    tmp = copy.deepcopy(T)
    tmp[P[i] - 1] = X[i]
    print(sum(tmp))

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 = [int(i) for i in input().split()]
M = int(input())
ans = ''
for i in range(M):
    goukei = sum(T)
    P, X = map(int,input().split())
    goukei = goukei + X - T[P-1]
    ans += str(goukei) + "\n"

print(ans[:-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)]

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

Solution (Python):
from copy import copy
N = int(input())
Tlist = list(map(int,input().split()))
M = int(input())
PXlist = [tuple(map(int,input().split())) for _ in range(M)]

for num,res in PXlist:
    tmp = copy(Tlist)
    tmp[num-1] = res
    print(sum(tmp))

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

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

Solution (Python):
n = int(input())
*pr, = map(int,input().split())
for i in range(int(input())):
  n, v = map(int, input().split())
  print(sum(pr)-pr[n-1]+v)

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

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

m = int(input())
f = lambda:map(int,input().split())
for i in range(m):
  n, d = f()
  
  mot = pr[n-1]
  pr[n-1] = d
  print(sum(pr))
  pr[n-1] = mot

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

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

Solution (Python):
import copy

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

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

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

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

Solution (Python):

N =int(input())
Ts =[int(j) for j in input().split()]
M =int(input())
List=[[int(j) for j in input().split()] for i in range(M)]

for i in range(M):
    Ts_ = Ts.copy()
    Ts_[List[i][0]-1] = List[i][1]
    print(sum(Ts_))

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


if __name__ == "__main__":
    main()

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

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

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

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

total = sum(T)

ans = []
for i in range(M):
    ans.append(total - T[drinks[i][0]-1] + drinks[i][1])

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

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

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

Solution (Python):



def main():
    ans = []

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

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    N = int(input())
    t = list(map(int, input().split()))
    M = int(input())

    main()

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

ans = []

for i in range(M):
    P, X = map(int, input().split())
    l = [j for j in T]
    l[P-1] = X
    ans.append(sum(l))
print('\n'.join(map(str, ans)))

Solution (Python):
N = int(input())
times = list(map(int,input().split(' ')))
dtimes = []
M = int(input())
for i in range(M):
  dtimes.append(list(map(int,input().split(' '))))
for drink in dtimes:
  print(sum(times) - times[drink[0]-1] + drink[1])

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

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

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

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

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

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
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(i) for i in input().split()]
M = int(input())
PX = [[int(i) for i in input().split()] for _ in range(M)]

Sum = sum(T)

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

Solution (Python):
N = int(input())
T = input().split()
T = [int(n) for n in T]
t_length = 0
for o in T:
    t_length += o
P = []
X = []
M = int(input())
for p in range(0, M):
    tmp = input().split()
    P.append(int(tmp[0]))
    X.append(int(tmp[1]))
for q in range(0, M):
    print(t_length - T[P[q]-1] + X[q])

Solution (Python):
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(m):
  x=listA[listB[i][0]-1]
  listA[listB[i][0]-1] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]-1]=x

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

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

ans = []
s = sum(Ts)
for PX in PXs:
    P, X = PX
    ans.append(s - Ts[P - 1] + X)

print("\n".join(map(str, 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)]

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

Solution (Python):
n,*t=map(int,open(0).read().split())
for p,x in zip(t[n+1::2],t[n+2::2]):print(sum(t[:n])-t[p-1]+x)

Solution (Python):
n,*t=map(int,open(0).read().split())
for p,x in zip(t[n+1::2],t[n+2::2]):print(sum(t[:n])-t[p-1]+x)

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

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

for i in list:
    print(i)

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

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

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

ans = sum(tt)
for i in range(m):
    print(ans - (tt[drinks[i][0]-1] - drinks[i][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):
a = int(input())
x = list(map(int, input().split()))
b = int(input())
for i in range(b):
    ta , tb = map(int, input().split()) 
    print(sum(x)+tb-x[ta-1])

Solution (Python):
N = int(input())
Tlist = 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(Tlist)-Tlist[PX[i][0]-1]+PX[i][1])

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

n = ip()                                     

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







m  =  ip()
s = []
for i in range(m):
    a,b= (int(i) for i in input().split())
    c = copy.copy(t)
    c[a-1] = b
    s.append(sum(c))
for i in range(len(s)):
    print(s[i])