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):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(T, PX):
    T = string_to_int(T)
    DRINKS = list(map(string_to_int, PX))
    sum_t = reduce(lambda acc, x: acc+x, T, 0)

    ret = []
    for d in DRINKS:
        i = d[0] - 1
        x = d[1]
        ret.append(sum_t - (T[i] - x))
    return ret


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    T = input()
    M = int(input())
    ret = solve(T, inputs(M))
    for r in ret:
        print(r)

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

total_time = sum(T)

for i in range(M):
    t = PX[i][0]-1

    print(total_time - (T[t] - PX[i][1]))

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

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)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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

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

for r in res:
    print(r)

Solution (Python):
_ = input()
lst = [int(i) for i in input().split()]
m = int(input())
mlist = [[int(i) for i in input().split()] for _ in range(m)]

for i in mlist:
  tmp = lst.copy()
  tmp[i[0]-1] = i[1]
  print(sum(tmp))

Solution (Python):
import copy

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


m = int(input())
for _ in range(m):
    idx, value = map(int, input().split())
    print(sum_t - t[idx - 1] + value)

Solution (Python):
import copy

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


n = int(input())
for i in range(n):
    idx, value = map(int, input().split())
    T = copy.deepcopy(t)
    t[idx - 1] = value
    print(sum(t))
    t = copy.deepcopy(T)

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

for i in range(t):
    array = list(map(int, input().split()))
    drink_list.append(array)

for i in range(t):
    b = a.copy()
    b[drink_list[i][0]-1] = drink_list[i][1]
    print(sum(b))

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

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

import copy
for i in range(M):
    UU=copy.deepcopy(T)
    UU[A[i][0]-1]=A[i][1]
    print(sum(UU))

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

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

Solution (Python):
from sys import stdin
from copy import deepcopy

n = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

for i in li:
    lin = deepcopy(t)
    lin[i[0]-1] = i[1]
    print(sum(lin))

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

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

for i in range(m):
	ans=0
	for j in range(n):
		if j==juice[i][0]-1:
			ans+=juice[i][1]
		else:
			ans+=t[j]
	print(ans)

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

cnt = 0
while cnt < M:
    P, X = map(int, input().split())

    ans = 0
    P -= 1
    for i in range(len(T)):
        if i == P: 
            ans += X
        else:
            ans += T[i]
    print(ans)
    cnt += 1

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

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

Solution (Python):


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


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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    T=LI()
    M=I()
    PX=LLIN(M)
    ans = sum(T)
    for i,(p,x) in enumerate(PX):
        print(ans - (T[p-1] - x))
if __name__ == '__main__':
    main()

Solution (Python):
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

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

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[px_li[j][0] - 1] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)

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

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

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

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

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

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

for i in range(M):
    t =  T.copy()
    t[px[i][0]-1] = px[i][1]
    print(sum(t))

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

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

for i in range(M):
    ans = 0
    ex = PX[i][0]-1
    ans += PX[i][1]
    for j in range(N):
        if j != ex:
            ans += T[j]
    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+x-t[p-1])

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

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






import copy

for i in range(m):
	test = copy.copy(t)
	test[p[i][0]-1] = p[i][1]
	
	
	print(sum(test))

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    T=list(map(int,input().split()))
    s=sum(T)
    m=int(input())
    PX=[tuple(map(int,input().split())) for _ in range(m)]
    for i in range(m):
        p,x=PX[i]
        p-=1
        print(s-T[p]+x)
resolve()

Solution (Python):
from collections import deque


def solve():
    N = int(input())
    Ti = tuple(map(int, input().split()))
    M = int(input())

    PXi = deque()
    for _ in range(M):
        PXi.append(tuple(map(int, input().split())))

    
    
    
    

    total = sum(Ti)

    ans = deque()
    for p, x in PXi:
        p -= 1
        before = Ti[p]
        after = x

        if before <= after:
            ans.append(total + abs(before - after))
        else:
            ans.append(total - abs(before - after))

    return ans


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)

Solution (Python):
N = int(input())
T = [int(a) for a in input().split()]
M = int(input())
X = [[int(a) for a in input().split()] for _ in range(M)]
s = sum(T)

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

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

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

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

Solution (Python):


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

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

Solution (Python):


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

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

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

Solution (Python):
import copy
n=int(input())
t=[int(i) for i in input().split()]
m=int(input())
for i in range(m):
    cur=copy.deepcopy(t)
    drink=[int(i) for i in input().split()]
    cur[drink[0]-1]=drink[1]
    print(sum(cur))

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

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

Solution (Python):
import copy

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

for i in range(M):
  TP = copy.copy(T)
  TP[l[i][0]-1] = l[i][1]
  print(sum(TP))

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

l = [int(i) for i in input().split()]
total = sum(l)

m = int(input())

drink = [[int(i) for i in input().split()] for _ in range(m)]

for i in drink:
    print(total + (i[1] - l[i[0]-1]))

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

Solution (Python):

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

Solution (Python):

import sys
input = sys.stdin.readline


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

total = sum(T)

Ans = []
for p,x in PX:
    Ans.append(total - T[p-1] + x)

for ans in Ans:
    print(ans)

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

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

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

Solution (Python):
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())
  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 i in range(m)]

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

Solution (Python):
def examB():
    N = I()
    T = LI()
    totalT = sum(T)
    M = I()
    ans = []
    for i in range(M):
        P, X =LI()
        ans.append(totalT + X - T[P-1])
    for v in ans:
        print(v)



import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

Solution (Python):

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

p = []
x = []

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

for i in range(m):
    t2 = t[:]
    t2[p[i]] = x[i]
    print(sum(t2))

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

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    t = inpl()
    m = inp()
    px = [inpl() for i in range(m)]
    for i in px:
        print(sum(t) - t[i[0]-1] + i[1])
if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [ list(map(int,input().split())) for _ in range(m) ]
import copy as c
for i in range(m):
    tmp = c.copy(t)
    tmp[px[i][0]-1] = px[i][1]
    print(sum(tmp))

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=[0];T.extend(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]+X)

Solution (Python):
A = int(input())
T = list(map(int,input().split()))
D = int(input())
defo = []
for _ in range(D):
  defo = T
  a,p = map(int,input().split())
  q = T[a-1] -p
  s = sum(defo)
  s = s-q
  print(s)

Solution (Python):
A = int(input())
T = list(map(int,input().split()))
D = int(input())
defo = []
for _ in range(D):
  defo = T
  a,p = map(int,input().split())
  q = T[a-1] -p
  s = sum(defo)
  s = s-q
  print(s)

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

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

ans=0

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

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

Solution (Python):
n = int(input())
L = [int(i) for i in input().split()]
m = int(input())
LL = []
for i in range(m):
  LL.append([int(i) for i in input().split()])

for i in range(m):
  LLL = list(L)
  LLL[LL[i][0]-1] = LL[i][1]
  print(sum(LLL))

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

d = int(input())

for i in range(d):
  p, x = map(int, input().split())
  copied = problems[:]
  copied[p - 1] = x
  print(sum(copied))

Solution (Python):
n = int(input())
T = input().split()
t = [int(s) for s in T] 
t_sum = 0
for i in range(len(t)):
    t_sum = t_sum + t[i]
m = int(input())
PX = []
for i in range(m):
    PX.extend(input().split())
px = [int(s) for s in PX]
for j in range(0,2*m-1,2):
    print(t_sum - t[(px[j]-1)] + px[j+1])

Solution (Python):
N = int(input())
T = list(map(int,input().split()))
M = int(input())
mat = [list(map(int,input().split())) for i in range(M)]
ans = [0]*M
time = sum(T)
for i in range(M):
    ans[i] = time-T[mat[i][0]-1]+mat[i][1]
for j in range(len(ans)):
    print(ans[j])

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

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

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

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

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

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

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

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


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

Solution (Python):
def main():
  n = int(raw_input())
  tasks = map(int, raw_input().split())
  m = int(raw_input())
  for _ in xrange(m):
    p, x = map(int, raw_input().split())
    total_time = sum(tasks) - tasks[p-1] + x
    print(total_time)

main()

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

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
sum_T = sum(T)
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_sum = sum(t)
m = int(input())

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

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

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

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

Solution (Python):



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

ttl = sum(l)

m = int(input())

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

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

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,x=map(int,input().split())
    a-=1
    print(s-t[a]+x)

Solution (Python):
_ = input()
A = list(map(int, input().strip().split(' ')))
A_sum = sum(A)
M = int(input().strip())
for _ in range(M):
  p,x = map(int, input().strip().split(' '))
  print(A_sum-A[p-1]+x)

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

Drink = []
for D in range(M):
    Drink.append(input().split()) 
    


AnsTime = 0
for t in range(N):
    AnsTime += int(T[t]) 




for Dec in range(M):
    DecreaseTime = AnsTime - (int(T[int(Drink[Dec][0])-1]) - int(Drink[Dec][1]) )
    print(DecreaseTime)

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

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

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

Solution (Python):
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    t = [int(x) for x in input().split()]
    m = int(input())
    improvements = []
    for i in range(m):
        drink = list(map(int, input().split()))
        tmp = t[drink[0] - 1]
        t[drink[0] - 1] = drink[1]
        improvements.append(reduce(lambda x, y: x + y, t))
        t[drink[0] - 1] = tmp
    for el in improvements:
        print(el)

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


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

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

n_s = sum(T)
for m in P:
    print(n_s - (T[m[0]-1] - m[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())
    ans=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=ans

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

Solution (Python):
def resolve():
    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)

resolve()

Solution (Python):


n = int(input())

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

m = int(input())

original = sum(time)

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

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

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

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())
Ps = list(map(int,input().split(" ")))
s = sum(Ps)
m = int(input())
for  _ in range(m):
  i,v = list(map(int,input().split(" ")))
  print(s - Ps[i-1] + v)

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

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())
  Ts_2 = copy.copy(Ts) 
  Ts_2[P-1] = x
  print(sum(Ts_2))

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t = list(map(int, input().rstrip('\n').split()))
    m = int(input().rstrip('\n'))
    px = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    st = sum(t)
    for p, x in px:
        print(st - t[p-1] + x)


if __name__ == '__main__':
    slove()

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

Solution (Python):
import copy

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

P = []
X = []
for _ in range(M):
    p, x = [int(i) for i in input().split()]
    P.append(p)
    X.append(x)

for i in range(M):
    a = copy.deepcopy(T)
    a[P[i] - 1] = X[i]
    print(sum(a))

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_total = sum(T)
for p, x in PX:
    print(t_total - T[p-1] + x)

Solution (Python):
def solve():
    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[:P-1]+[X]+T[P:]))
        
solve()

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

Solution (Python):
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
PX = [list(map(int,input().split())) for _ in range(M)]
for px in PX:
    print(sum(Ts) - Ts[px[0]-1] + px[1])

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

X = [PX[i][1] for i in range(M)]
for px in PX:
    print(sum(Ts) - Ts[px[0]-1] + px[1])

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

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

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