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

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

def calc(lis):
	T2 = T.copy()
	T2[lis[0]-1] = lis[1]
	return sum(T2)

for i in range(M):
	print(calc(P[i]))

Solution (Python):
import sys
input = sys.stdin.buffer.readline
N = int(input())
T = [0] + list(map(int, input().split()))
sum_T = sum(T)
M = int(input())

for _ in range(M):
    p, x = map(int, input().split())
    
    t = sum_T - T[p] + x
    print(t)

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

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

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[:P-1])+X+sum(T[P:]),end="\n")

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

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):
prob = int(input())
sec = [int(n)for n in input().split()]
su = sum(sec)
for _ in range(int(input())):
    p, x = map(int, input().split())
    print(su - sec[p - 1] + x)

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

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

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

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

Solution (Python):
from copy import deepcopy

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

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

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

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

Solution (Python):
N = int(input())
map_T = map(int, input().split())
list_T = list(map_T)
M = int(input())
sumtime = sum(list_T)

for i in range(M):
  map_PX = map(int, input().split())
  list_PX = list(map_PX)
  sumtime_drink = sumtime- list_T[list_PX[0]- 1]+ list_PX[1]
  print(sumtime_drink)

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


normal_sum = sum(ts)

for _ in range(int(input())):
    no, time = map(int, input().split())
    print(normal_sum - ts[no-1] + time)

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


normal_sum = sum(ts)

for _ in range(int(input())):
    no, time = map(int, input().split())
    print(normal_sum - ts[no-1] + time)

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

Solution (Python):
import collections
 

def inputStrOnebyOne():
    s = list(input())
    return s
 

def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    n = int(input())
    tlist = inputOnebyOne_Int()
    m = int(input())

    ret=0
    for i in range(m):
        p,x = map(int, input().split())
        ret = sum(tlist) - tlist[p-1] + x
        print(ret)
 
if __name__=='__main__':
    main()

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

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

total = sum(T)

for i in range(M):
  p,x = list(input().strip().split())
  p = int(p)
  x = int(x)
  print(total - 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())
    a = sum(t) - t[p-1] + x
    print(a)

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

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

for j in range(len(T_all)):
    print(T_all[j])

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

Tsum = sum(T)
for i in range(M):
  sa = T[PX[i][0]-1] - PX[i][1]
  print(Tsum - sa)

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

S=sum(t)

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

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

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

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

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

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())
    M = [X if j + 1 == P else T[j] for j in range(N)]
    print(sum(M))

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

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

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

        Y = T[P-1]
        T[P-1] = X

        print(sum(T))

        T[P-1] = Y




if __name__ == '__main__':

    ABC_50_B()

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [0]*m

for i in range(0,m):
  px[i] = input().split()
  
x = []

tmp = [0]*m

for i in range(0,m):
  tmp = t[:]
  
  tmp[int(px[i][0])-1] = int(px[i][1])
  
  
  x.append(sum(tmp))
  


for i in x:
  print(i)

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

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

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

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

Solution (Python):
from math import *

def cin(): 
    return map(int,input().split())

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

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

def ssplit(): 
    return list(input().split())

def printlist(l): 
    for i in l:
        print(i,end=" ")

def main():
    n = cino()
    t = cina()
    ans = sum(t)
    k = cino()
    for i in range(k):
      a,b = cin()
      print(ans+(b-t[a-1]))
      


if __name__ == '__main__':
    main()

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

M = int(input())


for _ in range(M):
    p,x = map(int,input().split())

    tmp = T[:]

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

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

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 px in PX:
    print(TSUM + px[1] - T[px[0]-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 = sum(t) - t[p - 1] + x
    print(ans)

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)

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

Solution (Python):
import copy

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

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    s  = sum(L)
    m = ii()
    for _ in range(m):
        p, x = mi()
        p -= 1
        print(s - L[p] + x)


if __name__ == "__main__":
    main()

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

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

sum_T = sum(T)
for problem, time in drinks:
    print(sum_T - T[problem - 1] + time)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
T = IL()
s = sum(T)
M = I()
D = ILL(M)
for m,t in D:
  P(s-T[m-1]+t)

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

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

Solution (Python):
n=int(input())
s=[int(i)for i in input().split()]
d=int(input())
a=0
for i in range(d):
  x,y=map(int,input().split())
  x-=1
  a=s[x]
  s[x]=y
  print(sum(s))
  s[x]=a

Solution (Python):
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = LI()
m = I()
p = []
x = []
for i in range(m):
    tmp = LI()
    p.append(tmp.pop(0)-1)
    x.append(tmp.pop(0))

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

Solution (Python):
n,*t=map(int,open(0).read().split());q=t[:n:-1]
while q:print(sum(t[:n])-t[q.pop()-1]+q.pop())

Solution (Python):
n,*t=map(int,open(0).read().split());T=sum(t[:n]);q=t[:n:-1]
while q:print(T-t[q.pop()-1]+q.pop())

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

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

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

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

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

Solution (Python):
from copy import copy

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

for px in px_list:
    p, x = px
    tmp_list = copy(t_list)
    tmp_list[p - 1] = x
    print(sum(tmp_list))

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

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

Solution (Python):
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [list(map(int, input().split())) for _ in range(M)]
for p in P:
    copy_p = T.copy()
    copy_p[p[0] - 1] = p[1]
    print(sum(copy_p))

Solution (Python):
import sys

N = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())

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

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

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

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

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

Solution (Python):

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

drink_num = int(input())

for i in range(drink_num):
    q, boost = map(int, input().split())
    print(sum(times) - times[q-1] + boost)

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

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

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

tsum=sum(tlist)
pxlist=[]
for i in range(M):
  p,x=map(int,input().split())
  print(tsum-(tlist[p-1]-x))

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

N = int(input().rstrip())

values = list(map(int, input().rstrip().split()))
keys = list(range(1,N+1))

q_dic = dict(zip(keys, values))
ans = []

M = int(input().rstrip())

drinks = []
for i in range(M):
  a, b = map(int, input().rstrip().split())
  items = {a: b}
  drinks.append(items)

for i in range(len(drinks)):
  key = list(drinks[i].keys())[0]
  val = list(drinks[i].values())[0]
  q_dic[key] = val
  ans.append(sum(q_dic.values()))
  q_dic = dict(zip(keys, values))

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
T = tuple(map(int, input().split()))
M = int(input())
drinks = [list(map(int, input().split())) for _ in range(M)]
for drink in drinks:
    total_time = sum(T) - (T[drink[0]-1] - drink[1])
    print(total_time)

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

def Main(N, T, M, P, X):
    ans = [0]*M
    for i in range(M):
        TT = T.copy()
        TT[P[i]-1] = X[i]
        ans[i] = sum(TT)
    return ans

res = Main(N, T, M, P, X)
for e in res:
    print(e)

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

    for px in pxs:
        ans = 0
        for i in range(n):
            if i+1 == px[0]:
                ans += px[1]
            else:
                ans += ts[i]
        print(ans)


if __name__ == "__main__":
    main()

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

ans = []

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

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

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

Solution (Python):
N = int(input())
TT = [int(i) for i in input().split()]
M = int(input())
PP = []
XX = []
for _ in range(M):
    P, X = [int(i) for i in input().split()]
    PP.append(P)
    XX.append(X)

maxTime = 0
sumTime = sum(TT)
for i in range(len(PP)):
    print(sumTime - (TT[PP[i] - 1] - XX[i]))

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

Solution (Python):
TestNum = int(input())
TimeList = list(map(int,input().split()))
DrinkNum = int(input())
DrinkList = [list(map(int, input().split())) for _ in range(DrinkNum)]
TimeSum = sum(TimeList)
for i in DrinkList:
    print(TimeSum - (TimeList[i[0] -1] - i[1]))

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

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

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

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

lt = list(map(int, input().split()))
tm1 = sum(lt)

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

Solution (Python):


def main():
    N = int(input())
    *T, = map(int, input().split())
    S = sum(T)
    M = int(input())

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


main()

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

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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
n = int(input())
t_list = list(map(int,input().split()))
m = int(input())
drink_list = [list(map(int,input().split())) 
              for nesya in range(m)]
sum_t_list = sum(t_list)
for drink in drink_list:
  a = drink[0]
  b = drink[1]
  c = t_list[a-1] - b
  print(sum_t_list - c)

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

d = []
for _ in range(m):
  d.append(tuple(map(int,input().split())))

for i,t_i in d:
  print(sum(t)-t[i-1]+t_i)

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

d = []
for _ in range(m):
  d.append(tuple(map(int,input().split())))

base = sum(t)
for i,t_i in d:
  print(base-t[i-1]+t_i)

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

Solution (Python):
import copy
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
A=[]
for i in range(M):
    B=T.copy()
    P,M=map(int,input().split())
    B[P-1]=M
    A.append(sum(B))
for t in A:
    print(t)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

total = sum(T)

for i in range(M):
	P_i = PX[i][0]
	X_i = PX[i][1]
	diff = T[P_i-1] - X_i
	print(total - diff)

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

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

sum_ = sum(t_input)

for i in range(m):
    p,x = map(int,px_input[i])
    print(sum_-t_input[p-1]+x)

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

Solution (Python):
n = int(input())
t_input = list(map(int,input().split()))
m = int(input())
ans_li = []
for i in range(m):
    p,x = map(int,input().split())
    tmp=0
    for i in range(n):
        if p-1==i:
            tmp+=x
        else:
            tmp+=t_input[i]
    ans_li.append(tmp)

for a in ans_li:
    print(a)

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

Solution (Python):
question_num = int(input())
question_resolve_time = list(map(int, input().split()))
drink_num = int(input())

drink_data = []
for i in range(0, drink_num):
    a = list(map(int, input().split()))
    drink_data.append(a)

not_drinking_time = sum(question_resolve_time)

for drink in drink_data:
    result_time = not_drinking_time - question_resolve_time[drink[0] - 1] + drink[1]
    print(result_time)

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

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

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

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)

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

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

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

Solution (Python):
N=int(input())
T=[int(x) for x in input().split()]
M=int(input())
PX=[]
for i in range(M):
    p,x=map(int,input().split())
    PX.append([p,x])
def sum(A):
    ans=0
    for i in range(len(A)):
        ans+=A[i]
    return ans
sum=sum(T)
for i in range(M):
    a=PX[i][0]
    b=PX[i][1]
    print(sum-T[a-1]+b)