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


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
T = stdin.readline().rstrip().split()
M = int(stdin.readline().rstrip())
P = [stdin.readline().rstrip().split() for _ in range(M)]

T_num = [int(n) for n in T]
P_num = [list(map(int, P_in)) for P_in in P]

for i in range(len(P_num)):
    list_tmp = T_num[:]
    index = P_num[i][0] - 1
    val = P_num[i][1]
    list_tmp[index] = val
    print(sum(list_tmp))

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

time = sum(ps)
for p,x in ds:
    p -= 1
    print(time - ps[p] + x)

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

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())
D = [list(map(int, input().split())) for k in range(M)]
S = sum(T)

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

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

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

Solution (Python):
N = int(input())
Time = list(map(int, input().split(' ')))
M = int(input())
Drink = []
for i in range(M):
    p, x = map(int, input().split(' '))
    tmp = Time[::]
    tmp.pop(p-1)
    s = sum(tmp) + x
    Drink.append(s)
for i in Drink:
    print(i)

Solution (Python):
input()
*a,=map(int,input().split())
for _ in[0]*int(input()):i,x=map(int,input().split());print(sum(a)-a[~-i]+x)

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()))
    print(sum(t) - 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):
    pi,xi = map(int,input().split())
    P.append(pi)
    X.append(xi)

tsum=sum(T[:N])

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

Solution (Python):
import math
import sys

def getinputdata():

    
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()


n = int(arr_data[0][0])


m = int(arr_data[2][0])

arr01 = list(map(int, arr_data[1]))




for i in range(3, 3 + m):
    
    arr02 = arr01.copy()
    
    arr02.pop(int(arr_data[i][0])-1)
    
    
    arr02.append(int(arr_data[i][1]))
    
    print(sum(arr02))

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

St = sum(t)

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

Solution (Python):
n = int(raw_input())
solvetime = map(int, raw_input().split())
solvesum = 0
for i in range(0, n):
	solvesum = solvesum + solvetime[i]

m = int(raw_input())
for i in range(0, m):
	inpt = map(int, raw_input().split())
	print solvesum - solvetime[inpt[0]-1] + inpt[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 = 0
    for j in range(N):
        if j == P-1:
            ans += X
        else:
            ans += T[j]
    print(ans)

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

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

Solution (Python):

n=int(input())

t=input()
t=t.split()

m=int(input())
px=[]
su=[]
for i in range(m):
    px.append(input().split())
    o=t[int(px[-1][0])-1]
    t[int(px[-1][0])-1]=int(px[-1][1])
    temp=0
    for i in t:
        temp=temp+int(i)
    su.append(temp)
    t[int(px[-1][0])-1]=o
    
for i in su:
    print(i)

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

M=int(input())
P=[None for i in range(M)]
X=[None for i in range(M)]

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

P= list(map(int,P)) 
X= list(map(int,X)) 


for i in range (M):
    temp= T[P[i]-1]

    T[P[i]-1]=X[i]
    print(sum(T))
    T[P[i] - 1]=temp

Solution (Python):





if __name__ == '__main__':
    problem_count = int(input())
    elapsed_times = list(map(int, input().split()))
    drink_kind_count = int(input())
    effects = [list(map(int, input().split())) for i in range(drink_kind_count)]

    total_elapsed_time = sum(elapsed_times)

    for problem_p, new_elapsed_time, in effects:
        print(total_elapsed_time + (new_elapsed_time - elapsed_times[problem_p - 1]))

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
c=int(input())
for _ 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()))
M = int(input())
P = []
X = []
for i in range(M):
    p, x = map(int, input().split())
    P.append(p)
    X.append(x)
sumT = sum(T)
for i in range(M):
    result = sumT - (T[P[i]-1] - X[i])
    print(result)

Solution (Python):
N=int(input())
T=[int(i) for i in 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())
S=sum(T)
for i in range(M):
    print(S-T[P[i]-1]+X[i])

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 i in range(m)]
x = sum(t)
for i in range(m):
	y = d[i][1]-t[d[i][0]-1]
	print(x+y)

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

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

Solution (Python):

N=input()
T=list(map(int,input().split()))
M=int(input())
go=[]
for c in range(M):
    P,X=map(int,input().split())
    place=P-1
    result=T[place]
    Result=result-X
    ans=sum(T)-Result
    go.append(ans)
for Ans in go:
    print(Ans)

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

Solution (Python):
N = int(input())
time = [0]*N
tmp = input().split()
total = 0
for i in range(N):
  time[i] = int(tmp[i])
  total += time[i]
M = int(input())
for j in range(M):
  tmp = input().split()
  print(total+int(tmp[1])-time[(int(tmp[0])-1)])

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
t = na()
m = ni()
p = [na() for _ in range(m)]

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

Solution (Python):
from copy import deepcopy

N = int(input())
T = [int(n) for n in input().split()]
M = int(input())
PX = []
for _ in range(M):
    PX.append(tuple([int(n) for n in input().split()]))

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

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


solve()

Solution (Python):
def calc(lis, m_lis):
    copy_list = lis[:]
    copy_list[m_lis[0] - 1] = m_lis[1]
    print(sum(copy_list))


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

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

Solution (Python):
n=int(input())
ti=list(map(int,input().split()))
m=int(input())
pi=[0for i in range(m)]
xi=[0for i in range(m)]
for i in range(m):
  pi[i],xi[i]=map(int,input().split())



for i in range(m):
  time=0
  for j in range(n):
    if(j==pi[i]-1):
      time+=xi[i]
    else:
      time+=ti[j]
    
  print(time)

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

Solution (Python):
N = int(input())
T = [0] + [int(i) for i in input().split()]
M = int(input())
D = [[int(i) for i in input().split()] for j in range(M)]
 
for p,x in D:
  tmp = T[p]
  T[p] = x
  print(sum(T))
  T[p] = tmp

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

Solution (Python):
N = int(input())
T = [0] + [int(i) for i in input().split()]
M = int(input())
D = [[int(i) for i in input().split()] for j in range(M)]

for p,x in D:
  tmp = T[p]
  T[p] = x
  print(sum(T))
  T[p] = tmp

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

K=sum(T)
for i in range(M):
    print(K-(T[P[i][0]-1]-P[i][1]))

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

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

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

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

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

for i in range(M):
    ans = times
    x = drink[i][0] - 1
    y = drink[i][1]
    ans += (y - problems[x])
    print(ans)

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

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

Solution (Python):

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

m = int(input())
s = sum(times)

for _ in range(m):
    prob, red = map(int, input().split())
    prob = prob - 1
    t = times[prob]
    print(s - t + red)

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

    for p, x in PX:
        s = 0
        for i, t in enumerate(T, 1):
            if p == i:
                t = x
            s += t
        print(s)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in [0]*m]
for _px in px:
    print(sum(t)-t[_px[0]-1]+_px[1])

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

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

A = T

M = int(input())

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

for i in range(M):
	
	Ans = 0
	
	a = T[PM[i][0] - 1]
	
	T[PM[i][0] - 1] = PM[i][1]
		
	Ans += sum(T)
	
	print(Ans)
	
	T[PM[i][0] - 1] = a

Solution (Python):

"""
Created on Wed Dec 20 17:36:04 2017

"""

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

drinkList = []

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

sumTime = sum(TList)

for d in drinkList:
    print(sumTime - TList[d[0]-1] + d[1])

Solution (Python):
num = int(input())
val = [int(x) for x in input().split()]
val_bk = val
kind = int(input())
array = []
for i in range(kind):
    array.append([int(x) for x in input().split()])

for j in array:
    bk = val[j[0]-1]
    val[j[0]-1] = j[1]
    print(sum(val))
    val[j[0] - 1] = bk

Solution (Python):
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    Px = [list(map(int, input().split())) for _ in range(M)]
    
    for x in range(M):
        t = 0
        for y in range(N):
            if y + 1 == Px[x][0]:
                t += Px[x][1]
            else:
                t += T[y]
        print(t)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
N = int(input())
T = [0] + list(map(int, input().split()))
M = int(input())
ans = []
for i in range(M):
    Pi, Xi, = map(int, input().split())
    tmp = T[:]
    tmp[Pi] = Xi
    ans.append(sum(tmp))
print(*ans, sep="\n")

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

Solution (Python):



"""050-b"""

import sys
import pprint
import re

import itertools
pp = pprint.PrettyPrinter(indent=2)

def main():
    """Main function."""
    N = int(input())
    Ts = list(map(int, input().split(' ')))
    M = int(input())
    sum_ = sum(Ts)
    for _ in range(M):
        p, x = list(map(int, input().split(' ')))
        print(sum_ - Ts[p-1] + x)

if __name__ == '__main__':
    sys.exit(main())

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

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

m = int(input())

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

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

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

all_sum = sum(ts)
for p, x in pxs:
    print(all_sum + (x - ts[p - 1]))

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


solve()

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

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

Solution (Python):





def main():
    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())
        p -= 1 
        print(s - T[p] + x)

if __name__ == "__main__": main()

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

x = sum(t)

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

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

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

Solution (Python):
N = int(input())
listT = [int(_) for _ in input().split()]
M = int(input())
total_listT = sum(listT)

answer = []
for i in range(M):
    temp = [int(_) for _ in input().split()]
    answer.append(total_listT - listT[temp[0]-1] + temp[1])

for _ in answer:
    print(_)

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

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

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

Solution (Python):
_ = input()
l = map(int,raw_input().strip().split())
n = int(raw_input())
for x in xrange(n):
	a = map(int,raw_input().strip().split())
	temp = l[a[0]-1]
	l[a[0]-1] = a[1]
	print(sum(l))
	l[a[0]-1] = temp

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

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

PP=[]
XX=[]

for i in range(M):
    P, X = map(int,input().split())
    PP.append(P)
    XX.append(X)
    
for j in range(0,M):
    TT=T[:]
    PPP=PP[j]
    TT[PPP-1]=XX[j]
    total=sum(TT)
    print(total)

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

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

Solution (Python):
N = int(raw_input())
T = map(int,raw_input().split(" "))
M = int(raw_input())
P = []
X = []
answer = []
for m in range(M):
	input_line = map(int,raw_input().split(" "))
	P = input_line[0]
	X = input_line[1]
	answer.append(sum(T) + X - T[P-1])

txt = ""
for a in answer:
	print a

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

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    t = read_int_list()
    m = read_int()
    p = [0] * m
    x = [0] * m
    for i in range(m):
        p[i], x[i] = read_int_list()
        p[i] -= 1

    s = sum(t)
    for i in range(m):
        j = p[i]
        res = s - t[j] + x[i]
        print(res)


main()

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    t = read_int_list()
    m = read_int()
    p = [0] * m
    x = [0] * m
    for i in range(m):
        p[i], x[i] = read_int_list()
        p[i] -= 1

    for i in range(m):
        res = 0
        for j in range(n):
            if j == p[i]:
                time = x[i]
            else:
                time = t[j]
            res += time
        print(res)


main()

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

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

m = int(input())

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

Solution (Python):
from collections import defaultdict


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

    for p, x in drink_list:
        total = 0
        for i, t in enumerate(T_list, start=1):
            if i == p:
                total += x
            else:
                total += t
        print(total)


if __name__ == '__main__':
    main()

Solution (Python):
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N = ri()
T = rli()
sm = sum(T)
M = ri()
for i in range(M):
    p, x = rli()
    print(sm - T[p-1] + x)

Solution (Python):
import copy
N = int(input())
t = [int(x) for x in input().split()]
p = []
for _ in range(int(input())):
	p.append([int(x) for x in input().split()])

result = []
ori_t = copy.deepcopy(t)
for i in p:
	t = copy.deepcopy(ori_t)
	t[i[0]-1] = i[1]
	result.append(sum(t))

for i in result:
	print(i)

Solution (Python):
num_of_problems = int(input())
times = input().split()
for i in range(num_of_problems):
    times[i] = int(times[i])
num_of_drinks = int(input())
changes = []
for i in range(num_of_drinks):
    l = input().split()
    l[0] = int(l[0])
    l[1] = int(l[1])
    changes.append(l)
for i in changes:
    diff = times[i[0]-1] - i[1]
    times[i[0]-1] = i[1]
    print(sum(times))
    times[i[0]-1] += diff

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

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

for i in range(M):
    P, X = [int(j) for j in input().split()]
    tmp = T[:]

    tmp[P-1] = X
    total.append(sum(tmp))

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

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


for d in Ds:
    print(sum(Ts) - Ts[d[0] - 1] + d[1])

Solution (Python):
import copy

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

Solution (Python):


import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        n = int(input())
        ts = list(map(int, input().split()))
        s = sum(ts)
        m = int(input())
        for i in range(m):
            p, x = map(int, input().split())
            print(s + (x - ts[p-1]))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)

Solution (Python):


import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        n = int(input())
        ts = list(map(int, input().split()))
        s = sum(ts)
        m = int(input())
        for i in range(m):
            p, x = map(int, input().split())
            print(s + (x - ts[p-1]))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)

Solution (Python):


import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        n = int(input())
        ts = list(map(int, input().split()))
        s = sum(ts)
        m = int(input())
        for i in range(m):
            p, x = map(int, input().split())
            print(s + (x - ts[p-1]))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()

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

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

Solution (Python):
import copy

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

t_ = copy.deepcopy(t)
for i in range(0, m):
    t_[px[i][0] - 1] = px[i][1]
    print(sum(t_))
    t_ = copy.deepcopy(t)

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

Solution (Python):

N = int(raw_input())
T = map(int, raw_input().split())
M = int(raw_input())
PX = [map(int, raw_input().split()) for i in xrange(M)]

S = sum(T)
for P, X in PX:
    print S - (T[P - 1] - X)

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
sum_t = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    ans = sum_t + x - t[p-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-1)
  X.append(Xi)

for p , x in zip(P,X):
  print(sum(T) - T[p] + x)

Solution (Python):

from copy import deepcopy


def main():
    problems = int(input())
    solve_times = [int(e) for e in input().split()]
    drinks = int(input())

    for i in range(drinks):
        solve_times_copy = deepcopy(solve_times)
        problem_idx, solve_time = [int(e) for e in input().split()]
        problem_idx -= 1
        solve_times_copy[problem_idx] = solve_time
        print(sum(solve_times_copy))


main()

Solution (Python):
mondai = int(raw_input())
time_array = raw_input().split(" ")
drink_num = int(raw_input())

for i in range(drink_num):
    d = raw_input().split(" ")
    m_i = int(d[0]) - 1
    d_time = int(d[1])

    s = 0
    for j in range(len(time_array)):
        if j == m_i:
            s += (d_time)
        else:
            s += int(time_array[j])
    print s

Solution (Python):



def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    time = []
    for i in range(m):
        time.append(list(map(int, input().split())))

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

if __name__ == '__main__':
    main()

Solution (Python):

"""
Created on Wed Feb 22 16:06:57 2017

@author: 0048005387
"""

N = input()
T = map(int, raw_input().split())

M = input()
PX=[]
for i in range(M):
    PX.append(map(int, raw_input().split()))

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

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

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

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