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):
count = int(input())
orline = input()
line = orline.split()
dri = int(input())
sum = 0
for i in range(dri):
  num = input().split()
  line[int(num[0]) - 1] = int(num[1])
  for j in range(count):
    sum += int(line[j])
  print(sum)
  sum = 0
  line[int(num[0]) -1] = orline.split()[int(num[0]) -1]

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

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

Solution (Python):
import copy

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

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

Solution (Python):
N = int(input())
T_l = [int(i) for i in input().split()]
M = int(input())
PX = [[int(i) for i in input().split()] for j in range(M)]

P = [i[0] for i in PX]
X = [i[1] for i in PX]

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

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

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

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

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

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

answer = 0
for _ in range(M):
    p, x = map(int, input().split())
    change = answer_time[p-1]
    answer_time[p-1] = x
    print(sum(answer_time))
    answer_time[p-1] = change

Solution (Python):
from copy import deepcopy
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())
    p.append(tmpp)
    x.append(tmpx)
for j in range(len(p)):
    tmplist = deepcopy(t)
    tmplist[p[j]-1] = x[j]
    print(sum(tmplist))

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

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

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

reg_sum = sum(time_li)

for item in drink_li:
    id = item[0] - 1
    diffrence = item[1] - time_li[id]
    print(reg_sum + diffrence)

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
all=sum(t)
for i in range(m):
  drink.append(list(map(int,input().split())))
for j in range(m):
  if drink[j][0]<=n:
    print(all-t[drink[j][0]-1]+drink[j][1])
  else:
    print(all)

Solution (Python):
z = int(input())
ar = list(map(int,input().split(" ")))
y = int(input())
count = 0
for i in range(y):
    l = list(map(int,input().split(" ")))
    for j,a in enumerate(ar):
        if j != l[0] -1:
            count += a
    count += l[1]
    print(count)
    count = 0

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

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
t = list(li())
total = sum(t)

m = ni()
px = []
for _ in range(m):
    p,x = li()
    p -= 1
    print(total - t[p] + x)

Solution (Python):
from sys import stdin


def main():
    n = next_int()
    t = [next_int() for _ in range(n)]

    m = next_int()
    ans = [0] * m

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

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


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin


def main():
    n = next_int()
    t = [next_int() for _ in range(n)]

    ans = []
    m = next_int()

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

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


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

P_X = []
X = []

for i in range(M):
    p_, x_ = map(int, input().split())
    P_X.append([p_, x_])

for i in range(M):
    p = P_X[i][0] - 1
    x = P_X[i][1]
    if N >= M:
        print(sum(T) -T[p] + x)
    else:
        if p < N :
            print(sum(T) -T[p] + x)
        else :
            print(sum(T))

Solution (Python):



"""
    入力は全て整数である
    1≦N≦100
    1≦Ti≦105
    1≦M≦100
    1≦Pi≦N
    1≦Xi≦105
"""
test = False

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

for _ in range(M):
    temp_P, temp_X = map(int, input().split())
    P.append(temp_P)
    X.append(temp_X)

if test:
    print('P =', P)
    print('X =', X)


def main():
    """
    飲まないときの時間を基準にして、飲んだ時の差分を引く。
    """
    default_time = sum(T)
    for i in range(M):
        dt = T[P[i] - 1] - X[i] 
        print(default_time - dt) 


if __name__ == '__main__':
    main()

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)
T_total = 0

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

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

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

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

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

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

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

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

Solution (Python):


N = int(input())
T = input().split()
for i in range(0, N):
    T[i] = int(T[i])
M = int(input())
for i in range(0, M):
    p, x = input().split()
    p = int(p)
    x = int(x)
    Time = sum(T) - T[p - 1] + x
    print(Time)

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

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

for i in ans:
    print(i)

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P, X, ans = [0]*M, [0]*M, []
base = sum(T)

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

for i in ans:
    print(i)

Solution (Python):
N=int(input())
T=list(map(int,input().split()))
M=int(input())
PX=[list(map(int,input().split())) for i in range(M)]
import copy
for i in range(len(PX)):
    TC=copy.deepcopy(T)
    TC[PX[i][0]-1]=PX[i][1]
    print(sum(TC))

Solution (Python):
n = int(input())
listT = list(map(int, input().split()))
sumT =0
index3 =0
while index3 < len(listT):
    sumT+=listT[index3]
    index3+=1
m = int(input())
listForL = []
index=0
while index < m:
    pXList = list(map(int, input().split()))
    listForL.append(pXList)
    index+=1

listForA = []
index2 =0
while index2 < len(listForL):
    sum = sumT - listT[listForL[index2][0]-1] + listForL[index2][1]
    listForA.append(sum)
    index2+=1

for ans in listForA:
    print(ans)

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

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

Solution (Python):
N = int(input())
T = [int(_) for _ in input().split()]
M = int(input())
Total = sum(T)
output = []
for i in range(M):
    p, x = map(int, input().split())
    output.append(Total - (T[p-1] - x))
for i in range(M):
    print(output[i])

Solution (Python):
n = int(input())
list_t = list((map(int, input().split())))
m = int(input())
count = 0
list_px = []
while count < m:
    list_px.append(list(map(int, input().split())))
    count += 1
list_t_sum = 0
for number in list_t:
    list_t_sum += number
for i in range(0,m):
    print(list_t_sum - list_t[list_px[i][0]-1] + list_px[i][1])

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

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

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

for i in range(M):
  print(def_sum-(T[drink[i][0]-1]-drink[i][1]))

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

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

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())
    result = sum(T[:P-1]) + X + sum(T[P:])
    print(result)

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

for i in ans:
    print(i)

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())
    tot=sum(t)
    tot=tot-t[p-1]+x
    ans.append(tot)
for i in ans:
    print(i)

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

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

    print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input())
T = [int(x) for x in 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):
n = int(input())
t_list = list(map(int,input().split()))
m = int(input())

for _ in range(m):
    temp_list = list(t_list)
    p,x = map(int,input().split())

    temp_list[p-1] = x
    print(sum(temp_list))

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

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

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

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

Solution (Python):
N = int(input())
T = [(i,int(x)) for i,x in enumerate(input().split(),1)]
M = int(input())
px = [input().split() for _ in range(M)]
for p,x in px:
  print(sum(int(x) if int(p) == i else t for i,t in T))

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

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

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

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)

num = sum(t)

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

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

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

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

for _ in range(m):
    p, x = input().split()

    ans = 0
    for i in range(n):
        if i == int(p) - 1:
            ans += int(x)
        else:
            ans += t[i]

    print(ans)

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

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

base_value = sum(T_list)

for i in range(M):
    print(base_value - (T_list[M_list[i][0]-1] - M_list[i][1]))

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

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())
    ans.append(sum(T[:p-1])+x+sum(T[p:]))

for _ in ans:
    print(_)

Solution (Python):

"""
Created on Thu Aug 23 22:02:16 2018
ABC050B
@author: maezawa
"""

n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for _ in range(m):
    pi, xi = list(map(int, input().split()))
    p.append(pi)
    x.append(xi)
    
standard = sum(t)
for i in range(m):
    stime = standard - (t[p[i]-1]-x[i])
    print(stime)

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

Solution (Python):
from copy import copy

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

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

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

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

M=int(input())

a=[]
for k in range(M):
    a.append(list(map(int,input().split())))

cal=sum(t)

for j in range(M):
    print(cal - t[a[j][0]-1] + a[j][1])

Solution (Python):
n = int(input())
tList = input().split(' ')

for i in range(len(tList)):
    tList[i] = int(tList[i])

m = int(input())
pList = []
xList = []

for j in range(m):
    p, x = input().split(' ')
    pList.append(int(p))
    xList.append(int(x))

for k in range(m):
    tListCopy = list(tList)
    tListCopy[pList[k]-1] = xList[k]
    print(sum(tListCopy))

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

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

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

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

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

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

Solution (Python):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
pm = [[int(j) for j in input().split()] for i in range(M)]
s = sum(T)
for i,M in pm: print(s-T[i-1]+M)

Solution (Python):


def main():
    n = int(input())
    t_list = list(map(int, input().split()))
    m = int(input())
    drink_list = [list(map(int, input().split())) for _ in range(m)]

    for drink in drink_list:
        p, x = drink
        ans = 0
        for i in range(1, n+1):
            if i == p:
                ans += x
            else:
                ans += t_list[i-1]
        print(ans)

if __name__ == '__main__':
    main()

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 range(M):
    temp = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    print(sum(T))
    T[P[i][0] - 1] = temp

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

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

Solution (Python):
n=int(input())
d={i+1:j for (i,j) in enumerate(map(int,input().split()))}
m=int(input())
for _ in range(m):
  a,b=map(int,input().split())
  s=sum([j if i!=a else b  for (i,j) in d.items()])
  print(s)

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

ans=sum(A)

for i in range(M):
  a,b=map(int,input().split())
  cnt=A[a-1]-b
  print(ans-cnt)

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

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

    total = 0
    for j in range(n):
        if j == (p - 1):
            total += x
        else:
            total += t[j]
    print(total)

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

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

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

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

S=sum(t)
m=int(input())
ans=[0]*m

for i in range(m):
    a,b=map(int,input().split())
    ans[i]=S+b-t[a-1]

for i in range(m):
    print(ans[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)]

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

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

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

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


for i in range(M):
        x,y = map(int,input().split())
        temp = L[x - 1]
        L[x - 1] = y
        print(sum(L))
        L[x - 1] = temp

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

if __name__ == '__main__':
    main()

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

if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

S = sum(T)

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

Solution (Python):


n = int(input())
T = list(map(int, input().split()))
m = int(input())
A = [list(map(int, input().split())) for _ in range(m)]
_sum = sum(T)

for a in A:
    print(_sum - T[a[0]-1] + a[1])

Solution (Python):
N = int(input())
T_list = list(map(int, input().split()))
M = int(input())
PX_list = []
for _ in range(M):
    PX_list.append(tuple(map(int, input().split())))
    
for i in PX_list:
    print(sum(T_list) + i[1] - T_list[i[0]-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)]
k=sum(t)
for i in range(m):
    print(k-t[px[i][0]-1]+px[i][1])

Solution (Python):


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


sum1 = sum(tests)

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

Solution (Python):


import copy

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

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

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

for i in range(M):
  time=0
  P=input().split()
  drink=int(P[0])
  for k in range(N):
    if(k+1 == drink):
      time+=int(P[1])
    else:
      time+=int(T[k])
  print(time)

Solution (Python):
import copy

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

drinks = []

for i in range(total_drinks):
  drinks.append(list(map(int, input().split())))

output_list = []
for i in range(total_drinks):
  output_list = copy.deepcopy(time_list)

  output_list[drinks[i][0] - 1] = drinks[i][1]
  print(sum(output_list))

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




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

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

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

Solution (Python):
N = int(raw_input())
T = map(int,raw_input().split())
S = sum(T)
M = int(raw_input())
for i in range(M):
  Pi, Xi = map(int,raw_input().split())
  print S + (Xi - T[Pi-1])

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

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

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

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

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

for i in range(M):
    array = input().split(" ")
    sum = 0
    for j in range(N):
        sum += int(TimeList[j])
    print(sum + int(array[1]) - int(TimeList[int(array[0])-1]))

Solution (Python):
from copy import copy
N = int(input())
problems = list(map(int,input().split()))
M = int(input())
for i in range(M):
    problems_temp = copy(problems)
    drink = list(map(int,input().split()))
    problems_temp[drink[0]-1] = drink[1]
    print(sum(problems_temp))

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a = []
for _ in range(m):
    a.append(list(map(int,input().split())))
for i in range(m):
    j = a[i][0]-1
    print('{}'.format(sum(t)- t[j] + a[i][1]))

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

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for k in range(M):
    p,x = (int(i) for i in input().split())
    time.append(total - T[p-1] + x)

for i in range(M):
    print(time[i])

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

Solution (Python):
import copy

n = int(input())
array = [int(x) for x in input().split()]
nn = int(input())
res = []
for i in range(nn):
    aarraayy = copy.copy(array)
    x, y = map(int, input().split())
    aarraayy[x-1] = y
    res.append(sum(aarraayy))

for j in res:
    print(j)