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):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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

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


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=list(map(int,input().split()))
    P.append(p)
    X.append(x)
for m in range(M):
    s=0
    for n in range(N):
        if n+1==P[m]:
            s+=X[m]
        else:
            s+=T[n]
       
    print(s)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    T=LI()
    M=I()
    P=[0]*M
    X=[0]*M
    for i in range(M):
        P[i],X[i]=MI()
    S=sum(T)
    for i in range(M):
        print(S-T[P[i]-1]+X[i])
    

main()

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

Solution (Python):
import numpy as np
N = int(input())
T_k = list(map(int,input().split()))
M = int(input())

Total_time_ord = sum(T_k)           
subtraction = 0
drink_time = Total_time_ord
d_list = np.array([])

for i in range(M):
    
    PX = list(map(int,input().split()))
    P = PX[0]
    X = PX[1]
    drink_cos = drink_time + X - T_k[P-1]
    d_list = np.append(d_list,drink_cos)
    drink_cos = Total_time_ord

for i in range(M):
    print("{}".format(int(d_list[i])))

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

Solution (Python):








def resolve():
    N=int(input())
    T=list(map(int,input().split()))
    M=int(input())
    P, X = [0] * M, [0] * M
    for i in range(M):
        P[i], X[i] = map(int, input().split())

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

resolve()

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

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

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

Solution (Python):
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []; x = []
s = sum(t)

for i in range(m):
    S,T = input().split()
    p.append(int(S))
    x.append(int(T))

for j in range(m):
    ans = s - (t[p[j]-1] - x[j])
    print(ans)

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

for _ in range(M):
  P, X = list(map(int, input().split()))
  sum = 0
  for i in range(len(Ts)):
    if i + 1 == P:
      sum += X
    else:
      sum += Ts[i]
  
  print(sum)

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

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

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

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

TList = input().split()

M = int(input())

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


for i in List:
    sum = 0
    for j in range(N):
        if int(i[0]) == int(j+1):
            sum = sum + int(i[1])
        else :
            sum = sum + int(TList[j])
    print(sum)

Solution (Python):
input1 = raw_input()

input2 = []
for str in raw_input().split():
    input2.append(int(str))

input3 = raw_input()

input4 = []
for num in range(int(input3)):
    input4.append(raw_input())

for value in input4:
    result = 0
    list1 = list(input2)
    value = value.split()
    list1[int(value[0]) - 1] = int(value[1])
    for num in list1:
        result = result + num
    print result

Solution (Python):
if __name__ == '__main__':
    
    
    n = int(input())
    
    t = [int(e) for e in input().split(' ')]
    
    m = int(input())
    
    p = []
    x = []
    for i in range(m):
        p_i, x_i = [int(e) for e in input().split(' ')]
        p.append(p_i)
        x.append(x_i)
    
    
    
    
    for drink_i in range(m):
        ans = 0
        
        for p_i in range(n):
            
            if p[drink_i] == p_i+1:
                
                
                ans += x[drink_i]
            else:
                
                
                ans += t[p_i]
        
        print(ans)

Solution (Python):
N=int(input())
T=[int(x)for x in input().split()]
M=int(input())
p=[0]*M
x=[0]*M
for i in range(M):
    p[i],x[i]=map(int,input().split())
k=0
for j in range(N):
    k+=T[j]
for i in range(M):
    ans=k+x[i]-T[p[i]-1]
    print(ans)

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

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

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

Solution (Python):


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

total = sum(s)

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

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

    S = sum(T)

    for p in P:
        d = T[p[0] - 1] - p[1]
        print(S - d)


if __name__ == "__main__":
    main()

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

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

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


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

Solution (Python):
import numpy as np

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

M = int(input())

P = np.ones(M)
X = np.ones(M)

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

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

Solution (Python):
N = int(input())
time = tuple(map(int,input().split()))
M = int(input())
time_2 = list(time)

for i in range(M):
    p, x = list(map(int,input().split()))
    time_2[p-1] = x
    ans = sum(time_2)
    print(ans)
    time_2[p-1] = time[p-1]

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

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 _ in range(M)]
tot=sum(T)
for p,x in px:
    print(tot-T[p-1]+x)

Solution (Python):
import copy



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

P_list = []
X_list = []
for m in range(M):
    p, x = map(int, input().split())
    P_list.append(p)
    X_list.append(x)

for p in range(M):
    T_d_list = copy.copy(T_list)
    T_d_list[P_list[p] - 1] = X_list[p]

    print(sum(T_d_list))

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

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

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

Solution (Python):

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

for i in px:
    henka=t[i[0]-1]-i[1]
    ans=sum_t-henka
    print(ans)

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

Solution (Python):
import numpy as np
import copy

N = int(input())
A = [int(i) for i in input().split()]
T = np.array(A)
M = int(input())
P = []
for i in range(M):
  a = [int(i) for i in input().split()]
  P.append(a)
for list in P:
    t = T.copy()
    t[list[0]-1] = list[1]
    print(np.sum(t))

Solution (Python):
n = int(input())
T = input().split(' ')
T = [int(x) for x in T]
N = int(input())
S = sum(T)
for i in range(N):
  line = input().split(' ')
  print(S-T[int(line[0])-1]+int(line[1]))

Solution (Python):
listP=[]
listX=[]
N=int(input())
T=input().split()
M=int(input())
for a in range(M):
    P,X=input().split()
    listP.append(int(P))
    listX.append(int(X))

for b in range(M):
    listT = [int(b) for b in T]

    listT[listP[b]-1]=listX[b]

    print(sum(listT))

Solution (Python):
import sys









mod = int(1e9+7)
INF = 1<<29

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

if __name__=='__main__':
    main()

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

for i in range(m):
    tmp=list(map(int,input().split()))
    drink.append(tmp)
total=0
for i in range(n):
    total+=t[i]
for i in range(m):
    ans=total
    ans-=t[drink[i][0]-1]
    ans+=drink[i][1]
    print(ans)

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

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

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

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

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

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


for i in range(m):
    x = q[:]
    x.pop((d[i][0])-1)
    x.insert((d[i][0]-1),d[i][1])
    print(sum(x))

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

  n=int(input())
  t=list(map(int,input().split()))
  m=int(input())
  px=[list(map(int,input().split())) for _ in range(m)]
  
  for i in range(m):
    print(sum(t)-t[px[i][0]-1]+px[i][1])
  
if __name__ == '__main__':
    main()

Solution (Python):
num=int(input())
times=list(map(int,input().split()))
M=int(input())
t=sum(times)
for a in range(M):
  P,X=map(int,input().split())
  print(t-times[P-1]+X)

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

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

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

for _ in range(M):
    a,b=map(int,input().split())
    res=sm+b-T[a-1]
    print(res)

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

if __name__ == '__main__':
    main()

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

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

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

for x in px:
    sub = x[1] - T[x[0] - 1]
    newSum = sumT + sub
    print(newSum)

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

n = int(readline())
T = list(map(int,readline().split()))
m = int(readline())
PX = [list(map(int,readline().split())) for i in range(m)]

class Input():
    def __init__(self,n,T,m,PX):
        self.n = n
        self.T = T
        self.m = m
        self.PX = PX

class Calc(Input):
    def __call__(self):
        time_sum = self.requre_sum()
        for i in range(self.m):
            substract = self.add_sub(i)
            print(time_sum - substract)
    
    def requre_sum(self):
        return sum(self.T)
    
    def add_sub(self,i):
        return self.T[self.PX[i][0]-1] - self.PX[i][1]


x = Calc(n,T,m,PX)

x()

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

Solution (Python):
N = int(input())
T_list = list(map(int, input().split()))
M = int(input())
X_list = []
for i in range(M):
    X = list(map(int, input().split()))
    X_list.append(X)
time_list = []
for i in range(M):
    time = 0
    for j in range(N):
        if X_list[i][0]-1 == j:
            time += X_list[i][1]
        else:
            time += T_list[j]
    time_list.append(time)
for i in range(M):
    print(time_list[i])

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

Solution (Python):


item_count = int(input().rstrip())
require_time = list(map(int, input().rstrip().split(" ")))
drink_count = int(input().rstrip())

total = sum(require_time)

ans = []
for i in range(drink_count):
    (p,x) = map(int, input().rstrip().split(" "))
    tmp = total - require_time[p-1] + x
    ans.append(tmp)


for i in ans:
    print(i)

Solution (Python):
import numpy as np

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

Solution (Python):
N = int(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())
T = list(map(int, input().split()))
M = int(input())

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

Solution (Python):
def main():
    problem_num = int(input())
    solve_time = list(map(int, input().split()))
    drink_variation = int(input())
    drinks = [tuple(map(int, input().split())) for _ in range(drink_variation)]
    max_solve_time = sum(solve_time)
    for drink in drinks:
        print(max_solve_time - solve_time[drink[0] - 1] + drink[1])


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

N = int(input())

T = np.array([int(i) for i in input().split()])

M =int(input())

PX = np.ones([M,2])

for i in range(M):
    PX[i][0],PX[i][1] = [int(i) for i in input().split()]
    
ans_pre = sum(T)

ans = np.ones(M)

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

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

Solution (Python):
import copy

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


for i in range(m):
    x,y = map(int,input().split())
    s = copy.copy(t)
    s[x-1] = y
    ans = 0

    for j in range(n):
        ans += s[j]

    print(ans)

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

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

Solution (Python):
import copy

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

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

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

Solution (Python):
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [list(map(int, input().split()))
    for _ in range(m)]

    main(n, t, m, p_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):
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
P = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    P.append(array)

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

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

ans = []
for _ in range(M):
    p, x = map(int, input().split())
    a = 0
    for i in range(N):
        if i + 1 == p:
            a += x
        else:
            a += T[i]

    ans.append(a)

for a in ans:
    print(a)

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

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

tmp = sum(T)

for i in range(M):
  print(tmp - (T[pm[i][0] - 1] - pm[i][1]))

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

for i in range(m):
  sum = copy
  a,b = map(int,input().split())
  sum += b - l[a-1]
  print(sum)

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

Solution (Python):
from copy import  copy
n=int(input())

*t,=map(int,input().split())
t=[0]+t
m=int(input())
for _ in range(m):
	p,x=map(int,input().split())
	nt=copy(t)
	nt[p]=x
	print(sum(nt))

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

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

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

Solution (Python):
import numpy as np
N = int(input())

time=np.array(input().split(),dtype=np.int64)
M = int(input())

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


sumT=np.sum(time)
for i in range(M):
    PP = p[i]

    tot = sumT - time[PP-1] + x[i]
    print(tot)

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

for i in range(M):
    P_X.append(list(map(int, input().split())))

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

Solution (Python):



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


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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
f = lambda:map(int,input().split())
n = int(input())
l = list(f())
m = int(input())
for i in range(m):
  p,x = f()
  print(sum(l)-l[p-1]+x)

Solution (Python):

def pin(type=int):
    return map(type,input().split())

"""
M種類のうちの1個飲める
"""


N=int(input())
T=list(pin())
M=int(input())
Drinks=([tuple(pin()) for _ in range(M)])
p=[0]*N
for i in range (M):
    j=sum(T)
    print(j-T[Drinks[i][0]-1]+Drinks[i][1])

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

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
a=[[int(i) for i in input().split()] for l in range(m)]
for y in a:
    w=[]
    for x in range(len(t)):
        if y[0]-1==x:w.append(y[1])
        else:w.append(t[x])
    print(sum(w))

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)

ans=[]
m=sum(T)
for i in range(M):
    m=sum(T)
    m=m-T[P[i]-1]
    m=m+X[i]
    ans.append(m)

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

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

Solution (Python):
n = int(input())
tl = list(map(int, input().split()))
m = int(input())
pl = list(list(map(int, input().split())) for _ in range(m))

t_sum = sum(tl)
for p in pl:
    print(t_sum - (tl[p[0] - 1] - p[1]))

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

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

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

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

for a in ans:
    print(a)

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

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

Solution (Python):
n = int(input())
tl = list(map(int, input().split()))
m = int(input())
sum_time = sum(tl)
for _ in range(m):
    p, x = map(int, input().split())
    print(sum_time - tl[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):
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1

Solution (Python):
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1

Solution (Python):
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1

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

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

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

s = sum(t)

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

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())
    ans.append(sum(T) - T[P-1] + X)
print(*ans, sep="\n")

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

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

Solution (Python):
N=int(input())
T_N=input().split()
list_time = []
for i in range(N):
    list_time.append(int(T_N[i]))

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

    ans=sum+x-list_time[p-1]
    print(ans)

Solution (Python):
n = int(input())
t_N = input().split()
list_Time = []
for id in range(n):
    list_Time.append(int(t_N[id]))
sum = sum(list_Time)
m = int(input())
for id in range(m):
    p, x = map(int, input().split())
    answer = sum + x - list_Time[p - 1]
    print(answer)

Solution (Python):


import copy

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


if __name__ == "__main__":
    main()

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