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

t_sum = sum(t)

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

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

for i in range(M):
  drink=list(map(int,input().split()))
  result=sum(li)-li[drink[0]-1]+drink[1]
  print(result)

Solution (Python):
N=int(input())
T=[int(x) for x in input().split()]
M=int(input())
P=[]
X=[]
for i in range(M):
    p1,x1=(int(d) for d in input().split())
    P.append(p1)
    X.append(x1)
sum1=0
for i in range(N):
    sum1+=T[i]
for i in range(M):
    temp=sum1
    temp=temp-T[P[i]-1]+X[i]
    print(temp)

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

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

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

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

m = int(input())

p = []

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

for ii in range(m):
    if p[ii][0] <= n:
        total_time = sum(t) - t[p[ii][0]-1] + p[ii][1]
    else:
        total_time = sum(t)
    
    print(total_time)

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

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

m = int(input())

p=[]
x=[]
for _ in range(m):
    pp, xx= map(int, input().split())
    p.append(pp)
    x.append(xx)

for i in range(m):
    count=x[i]
    for j in range(n):
        if j==p[i]-1:
            pass
        else:
            count+=t[j]
    print(count)

Solution (Python):

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

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

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

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

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

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

M = int(input())

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

Solution (Python):
num = int(input())
time = list(map(int, input().split()))
drink = int(input())
eff = [list(map(int, input().split())) for i in range(drink)]

baseT = sum(time)
for i in range(drink):
    print(baseT - time[eff[i][0]-1] + eff[i][1])

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
tt=list(map(int,input().split()))
s=sum(tt)
m=int(input())
for _ in range(m):
    p,x=map(int,input().split())
    print(s-tt[p-1]+x)

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

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

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

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

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

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

T = [int(x) for x in input().split()]
sumT = sum(T)

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

Solution (Python):
n=int(input())
T=[int(i) for i 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)

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 i in range(m):
  ans = s - t[PX[i][0]-1] + PX[i][1]   
  print(ans)

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

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

p = []
x = []
for _ in range(m):
    pi, xi = map(int, input().split())
    p.append(pi)
    x.append(xi)

for i in range(m):
    pi = p[i]
    xi = x[i]
    ans = 0
    for j in range(n):
        if j + 1 == pi:
            ans += xi
        else:
            ans += t[j]
    print(ans)

Solution (Python):
N = int(input())
tList = list(map(int, input().split()))
M = int(input())
pLst = [list(map(int, input().split())) for i in range(M)]
ansLst = [0] * M

for i in range(M):
    tmp = 0
    for j in range(N):
        if j == (pLst[i][0] - 1):
            tmp += pLst[i][1]
        else:
            tmp += tList[j]

    ansLst[i] = tmp

for i in ansLst:
    print(i)

Solution (Python):
N = int(input())
T = [int(x) for x in input().split()]
total = sum(T)
M = int(input())
D = [None]*M
for i in range(M):
  D[i] = [int(x) for x in input().split()]
  D[i][0]-=1
  
for p, x in D:
  print(total - (T[p] - x))

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

Solution (Python):
N = int(input())
times = list(map(int, input().split()))
M = int(input())
sum_t = sum(times)
for _ in range(M):
  dist, time = map(int, input().split())
  if times[dist-1] >= time:
    print(sum_t-(times[dist-1]-time))
  else:
    print(sum_t+(time-times[dist-1]))

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):
  time = 0
  for j in range(n):
    if j == p[i][0]-1:
      time += p[i][1]
    else:
      time += t[j]
    
  print(time)

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

Solution (Python):

n = int(input())
T = [int(el) for el in input().split(' ')]
m = int(input())
total_T = sum(T)
d = {}
for i in range(m):
    p, x = [int(el) for el in input().split(' ')]
    print(total_T - (T[p-1] - x))

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


if __name__ == '__main__':
    main()

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

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

A = sum(T)

for i in range(M):
    p = P[i]
    x = X[i]
    print(A - T[p-1] + x)

Solution (Python):
n=int(input())
timelist=[int(i) for i in input().split()]
drinknum=int(input())
for i in range(drinknum):
    timelist2=timelist[:]
    qnum,time=[int(i) for i in input().split()]
    timelist2[qnum-1]=time
    sumtime=0
    for t in timelist2:
        sumtime+=t
    print(sumtime)

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

import sys, math, fractions, itertools


def solve(N: int, T: "List[int]", M: int, P: "List[int]", X: "List[int]"):
    sm = sum(T)
    for i in range(M):
        p = P[i]
        x = X[i]
        print(sm - T[p-1] + x)
    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):
import  numpy   as np
import  copy   
i_N =   int(input())
i_T =   input().split()
i_T =   np.array(i_T).astype(type(i_N))
i_M =   int(input())
i_X =   []
for i in range(i_M):
    i_tmp   =   input().split()
    i_X.append(i_tmp)

for P,X in i_X:
    i_calc  =   copy.deepcopy(i_T)
    i_calc[int(P)-1]  =   int(X)
    print(np.sum(i_calc))

Solution (Python):
import copy
N=int(input())
Tn=[int(x) for x in input().split()]
M=int(input())
for _ in range(M):
  P,X=[int(x) for x in input().split()]
  tTn=copy.deepcopy(Tn)
  tTn[P-1]=X
  print(sum(tTn))

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

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

Solution (Python):
n=int(input())
t=input().split()

m=int(input())
px=[]
for i in range(m):
  px.append(input().split())
res=0
for j in range(1,m+1):
  for k in range(1,n+1):	
    if k==int(px[j-1][0]):
      res+=int(px[j-1][1])
      
    else:
      res+=int(t[k-1])
      
  print(res)
  res=0

Solution (Python):

from collections import Counter
import sys

def main():

    num = int(input())
    data = list(map(int, input().split()))
    num_d = int(input())
    cheet_data = [list(map(int, input().split())) for i in range(num_d)]

    sum_data = sum(data)

    for i in range(num_d):
        a, b, = cheet_data[i]
        ans = sum_data - data[a - 1] + b
        print(ans)




if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
t0 = list(map(int, input().split()))
m = int(input())
px = []
while True:
    try:
        px.append(list(map(int, input().split())))
    except:
        break;
import copy

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

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

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

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

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

M = int(input())

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

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())
    sum = 0
    for j in range(p - 1):
        sum = sum + T[j]
    sum = sum + x
    for j in range(p , N):
        sum = sum + T[j]
    print(sum)

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

Solution (Python):

Nvar = int(input())
T_list = list(map(lambda x:int(x),input().split(" ")))
M_var = int(input())
P_list = []
for i in range(M_var):
    P_list.append(list(map(lambda x:int(x),input().split(" "))))


for d_num in range(M_var):
    time_sum = 0
    for q_num in range(Nvar):
        if q_num==P_list[d_num][0]-1:
            time_sum += P_list[d_num][1]
        else:
            time_sum += T_list[q_num]
    print(time_sum)

Solution (Python):
a = int(input())
b = list(map(int, input().split()))

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

e = sum(b)
for i in range(c):
    print(e - b[d[i][0]-1] + d[i][1])

Solution (Python):
n = int(input())
t  = list(map(int, input().split()))
m = int(input())
problem = []
for _ in range(m):
  hoge = list(map(int, input().split()))
  problem.append(hoge)
for i, fuga in enumerate(problem):
  drink_p, drink_p_time= fuga
  res = 0
  for p, p_time in enumerate(t):
    if(p == drink_p-1):
      res += drink_p_time
    else:
      res += p_time
  print(res)

Solution (Python):
N = int(input())
Problems = list(map(int, input().split()))
M = int(input())
arr = []
for i in range(M):
  P, T = map(int, input().split())
  sum = 0
  for j in range(N):
    if j != P - 1:
      sum += Problems[j]
    else:
      sum += T
  arr.append(sum)
for num in arr:
  print(num)

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, T: "List[int]", M: int, P: "List[int]", X: "List[int]"):
    for j in range(M):
        ret = 0
        for i in range(N):
            if i == P[j] - 1:
                ret += X[j]
            else:
                ret += T[i]
        print(ret)
    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):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a = ["a", "i", "u", "e", "o"]
    c = S()
    if c[0] in a:
        print("vowel")
    else:
        print("consonant")
    return


def B():
    _ = II()
    t = LI()
    tsum = sum(t)
    for _ in range(II()):
        p, x = LI()
        print(tsum - t[p - 1] + x)
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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

drinks = []
for i in range(int(input())):
    drinks.append([int(i) for i in input().split()])

for i, j in drinks:
    cp = list(Ts)
    cp[i - 1] = j
    print(sum(cp))

Solution (Python):
n = int(input())
time_list = list(map(int,input().split()))
m = int(input())
drink_list = [list(map(int,input().split())) for _ in range(m)]
sum_time = sum(time_list)

for d in drink_list:
    effect_index = d[0] - 1
    effect_time = d[1]
    print(sum_time - time_list[effect_index] + effect_time)

Solution (Python):
N=int(input())
T=[int(x) for x in 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()))

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

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

Solution (Python):

N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = list()
X = list()
res = [0]*M

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

for e in res:
    print(e)

Solution (Python):
n=int(input())
q=input().split()
sum=0
for i in range(n):
    sum+=int(q[i])

d=int(input())
for j in range(d):
    a,t=map(int,input().split())
    print(sum-int(q[a-1])+t)

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

for i in range(m):
    ans = time_li.copy()
    s,t = map(int,input().split())
    ans[s-1] = t
    print(sum(ans))

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

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

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from operator import mul
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def COMBINATION(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    r = min(n-r, r)
    if r == 0:
        return 1
    o = reduce(mul, range(n, n - r, -1))
    u = reduce(mul, range(1, r + 1))
    return o // u
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
t = LI()
m = II()
drink = [LI() for _ in range(m)]
tsum = sum(t)
for p, x in drink:
    print(tsum - t[p-1] + x)

Solution (Python):
import sys
n=int(input())
lineas=sys.stdin.readline()
arr=[]
arr=lineas.split()
arr=list(map(int,arr))
arr.insert(0,0)
m=int(input())
suma=0
lineas2=sys.stdin.readlines()
for i in range(m):
  arr2=lineas2[i].split()
  p=int(arr2[0])
  x=int(arr2[1])
  arr3=arr[:]
  arr3[p]=x
  for i in arr3:
    suma=suma+i
  print(suma)
  suma=0

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

time = sum(T)

for k in range(M):
    print(time - T[D[k][0]-1] + D[k][1])

Solution (Python):

N = int(input())

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

M = int(input())

summ = sum(T)

for i in range(M):

    P,X = map(int,input().split())

    ans = summ - T[P - 1] + X
    print (ans)

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

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

Solution (Python):
N = int(input())
T = [int(i) for i in 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()))
s = sum(t)
m = int(input())

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

for i in res:
    print(i)

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

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

for i in range(m):
    print(_sum - (t[p[i]]-x[i]))

Solution (Python):
def main():
    n = int(input())
    t = list(map(int,input().split(' ')))
    m = int(input())
    d = []
    for i in range(m):
        d.append(list(map(int,input().split(' '))))
    s = sum(t)
    for i,j in d:
        print(s-t[i-1]+j)
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
T = [int(t) for t in input().split()]
M = int(input())
P, X = [], []
for m in range(M):
    line = input().split()
    P.append(int(line[0]))
    X.append(int(line[1]))

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

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

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

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

Solution (Python):
import copy
a = int(input())
b = input().split(" ")
c = int(input())
for i in range(c):
  second = 0
  d = input().split(" ")
  e = copy.deepcopy(b)
  e[int(d[0])-1] = d[1]
  for i in range(a):
    second += int(e[i])
  print(second)

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
T = [int(x) for x in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
sum_T = sum(T)

for i,j in data:
    print(sum_T - T[i-1] + j)

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

s = sum(lit)
for i in range(m):
  print(s-lit[lid[i][0]-1]+lid[i][1])

Solution (Python):


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

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

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

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

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

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

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

Solution (Python):
a = int(input())
b = list(map(int,input().split()))
c = int(input())

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

Solution (Python):


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

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())
lstT = [int(i) for i in input().split()]
m = int(input())

total = sum(lstT)
lst_Ans = []

for i in range(m):
    p,x = map(int,input().split())
    ans = total - lstT[p-1] + x
    lst_Ans.append(ans)

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

Solution (Python):
N = int(input())
T = [int(i) for i in 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):
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

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

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

    
    
    
    
    
    
    
    


if __name__ == "__main__":

    main()

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

    p = [0 for i in range(m)]
    x = [0 for i in range(m)]

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

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


if __name__ == "__main__":

    main()

Solution (Python):



N, T_li, M, = int(input()), list(map(int, input().split())), int(input())
P_li = [[int (i) for i in input().split()] for j in range(M)]
dummy = 0

for i in range(M):
    dummy = T_li[P_li[i][0] - 1]
    T_li[P_li[i][0] - 1] = P_li[i][1]
    print(sum(T_li))
    T_li[P_li[i][0] - 1] = dummy

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

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

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

for i in range(M):
	print(sum(d_list[i]))

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

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

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

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):
    cnt = 0
    P, X = map(int, input().split())
    for j in range(N):
        if j == P-1:
            cnt += X
        else:
            cnt += T[j]
    print(cnt)