AtCoder Beginner Contest 050 - Contest with Drinks Easy

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-----
3
2 1 4
2
1 1
2 3

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

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


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


N = int(input())
L1 = list(map(int, input().split()))
M = int(input())
for _ in range(M):
	(x, y) = map(int, input().split())
	print(sum(L1) - L1[x - 1] + y)


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


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


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)


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


num_problems = int(input())
t = [int(n) for n in input().split()]
total = sum(t)
num_drinks = int(input())
for i in range(num_drinks):
	(m_id, m_val) = [int(n) for n in input().split()]
	ans = total - t[m_id - 1] + m_val
	print(ans)


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


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)


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


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


n = int(input())
l = list(map(int, input().split()))
l = [0] + l
s = sum(l)
k = int(input())
for _ in range(k):
	(m, n) = map(int, input().split())
	print(s - l[m] + n)


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


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


from typing import List

def answer(n: int, t: List[int], m: int, pxs: List[List[int]]) -> str:
	result = []
	for px in pxs:
		t_copy = t.copy()
		t_copy[px[0] - 1] = px[1]
		result.append(str(sum(t_copy)))
	return '\n'.join(result)

def main():
	n = int(input())
	t = list(map(int, input().split()))
	m = int(input())
	pxs = [list(map(int, input().split())) for _ in range(m)]
	print(answer(n, t, m, pxs))

def __starting_point():
	main()
__starting_point()


N = int(input())
T = [int(i) for i in 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)


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


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


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


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


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


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


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


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


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)


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


import copy

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

def __starting_point():
	main()
__starting_point()


N = int(input())
T = list(map(int, input().split()))
M = int(input())
drink = []
for i in range(M):
	(P, X) = map(int, input().split())
	drink.append([P, X])
for j in range(len(drink)):
	(P, X) = drink[j]
	time = X + sum(T) - T[P - 1]
	print(time)


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


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


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


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


(n, t) = (int(input()), list(map(int, input().split())))
T = sum(t)
print(*[T - t[i - 1] + j for (i, j) in [list(map(int, input().split())) for _ in range(int(input()))]], sep='\n')


n = int(input())
T = list(map(int, input().split()))
m = int(input())
D = [tuple(map(int, input().split())) for _ in range(m)]
sum_T = sum(T)
for i in range(m):
	print(sum_T - T[D[i][0] - 1] + D[i][1])


((n,), t, (m,), *d) = [[*map(int, i.split())] for i in open(0)]
s = sum(t)
for (p, x) in d:
	print(s - t[p - 1] + x)


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


import copy
n = int(input())
li = list(map(int, input().split()))
lis = copy.copy(li)
m = int(input())
dri = [list(map(int, input().split())) for i in range(m)]
for i in range(len(dri)):
	lis = copy.copy(li)
	lis[dri[i][0] - 1] = dri[i][1]
	print(sum(lis))


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)
Sum = sum(T)
for i in range(M):
	print(Sum - T[P[i] - 1] + X[i])


n = int(input())
timeList = list(map(int, input().split()))
m = int(input())
argList = [list(map(int, input().split())) for _ in range(m)]
res_time = sum(timeList)
for a in argList:
	print(res_time - timeList[a[0] - 1] + a[1])


N = int(input())
T = input()
M = int(input())
P = [input() for i in range(M)]

def ans050(N: int, T: str, M: int, P: list):
	T_list = list(map(int, T.split()))
	ans_list = []
	for i in range(M):
		T_list = list(map(int, T.split()))
		P_list = list(map(int, P[i].split()))
		del T_list[P_list[0] - 1]
		T_list.append(P_list[1])
		ans_list.append(sum(T_list))
	return ans_list
for i in range(M):
	print(ans050(N, T, M, P)[i])


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


n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
for i in range(m):
	sum = 0
	count = 1
	(p, x) = list(map(int, input().split()))
	for j in t:
		if p == count:
			sum += x
		else:
			sum += j
		count += 1
	print(sum)


N = int(input())
times = list(map(int, input().split()))
M = int(input())
drinks = [tuple(map(int, input().split())) for _ in range(M)]
time_sum_raw = sum(times)
for (pi, xi) in drinks:
	print(time_sum_raw - times[pi - 1] + xi)


n = int(input())
d = list(map(int, input().split()))
s = sum(d)
m = int(input())
for i in range(m):
	(k, v) = map(int, input().split())
	print(s - d[k - 1] + v)


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


import sys, bisect
from sys import stdin, stdout
from bisect import bisect_left, bisect_right, bisect, insort, insort_left, insort_right
from math import gcd, ceil, floor, sqrt
from collections import Counter, defaultdict, deque, OrderedDict
from queue import Queue, PriorityQueue
from string import ascii_lowercase
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 998244353
mod = 10 ** 9 + 7

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, ceil(sqrt(n)) + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return list(map(int, stdin.readline().split()))

def pr(n):
	stdout.write(str(n) + '\n')

def DFS(dictionary, vertex, visited):
	visited[vertex] = True
	stack = [vertex]
	print(vertex)
	while stack:
		a = stack.pop()
		for i in dictionary[a]:
			if not visited[i]:
				print(i)
				visited[i] = True
				stack.append(i)

def BFS(dictionary, vertex, visited):
	visited[vertex] = True
	q = deque()
	q.append(vertex)
	while q:
		a = q.popleft()
		for i in dictionary[a]:
			if not visited[i]:
				visited[i] = True
				q.append(i)
				print(i)

def soe(limit):
	l = [1] * (limit + 1)
	l[0] = 0
	l[1] = 0
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def gcd(a, b):
	while b:
		a = a % b
		(b, a) = (a, b)
	return a

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	n = inp()
	l = li()
	s = sum(l)
	d = {i + 1: l[i] for i in range(n)}
	m = inp()
	for i in range(m):
		x = s
		(a, b) = mp()
		x -= d[a]
		x += b
		pr(x)
for _ in range(1):
	solve()


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


n = int(input())
t = list(map(int, input().split()))
for a in range(int(input())):
	(x, y) = map(int, input().split())
	print(sum(t) + y - t[x - 1])


n = int(input())
t = tuple(map(int, input().split()))
m = int(input())
x = [list(map(int, input().split())) for _ in range(m)]
i = 0
for x[i] in x:
	l = list(t)
	j = x[i][0] - 1
	k = x[i][1]
	i += i
	l[j] = k
	print(sum(l))


import sys
input = sys.stdin.readline
import copy

def main():
	questions = []
	dp = []
	n = int(input())
	questions = list(map(int, input().split()))
	m = int(input())
	drinks = [list(map(int, input().split())) for _ in range(m)]
	for drink in drinks:
		dp = copy.deepcopy(questions)
		dp[drink[0] - 1] = drink[1]
		print(sum(dp))

def __starting_point():
	main()
__starting_point()


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


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


import copy
n = int(input())
t = [int(x) for x in input().split()]
m = int(input())
p = []
for i in range(m):
	p.append([int(x) for x in input().split()])
for i in range(m):
	r = copy.copy(t)
	r[p[i][0] - 1] = p[i][1]
	print(sum(r))


x = int(input())
y = list(map(int, input().split()))
z = int(input())
for i in range(z):
	(a, b) = list(map(int, input().split()))
	print(sum(y) - y[a - 1] + b)


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


n = int(input())
t_lst = list(map(int, input().split()))
m = int(input())
px_lst = [list(map(int, input().split())) for _ in range(m)]
time_lst = []
for i in range(m):
	problem = px_lst[i][0] - 1
	time = px_lst[i][1]
	before = t_lst[problem]
	t_lst[problem] = time
	time_lst.append(sum(t_lst))
	t_lst[problem] = before
for i in range(m):
	print(time_lst[i])


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


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


(n, tt, m, *px) = [list(map(int, s.split())) for s in open(0)]
stt = sum(tt)
for (p, x) in px:
	print(stt - tt[p - 1] + x)


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


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


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


n = int(input())
T = tuple(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)


quiznum = int(input())
timeline = input().split(' ')
timeline = [int(n) for n in timeline]
time_0 = 0
for i in range(quiznum):
	time_0 += timeline[i]
medinum = int(input())
for i in range(medinum):
	temp_line = input().split(' ')
	a = int(temp_line[0])
	b = int(temp_line[1])
	time = time_0 - timeline[a - 1] + b
	print(time)


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


n = int(input())
t = list(map(int, input().split()))
m = int(input())
while m:
	(p, x) = map(int, input().split())
	print(sum(t) - t[p - 1] + x)
	m -= 1


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


N = int(input())
T = list(map(int, input().split()))
M = int(input())
S = sum(T)
for i in range(M):
	(a, b) = map(int, input().split())
	SS = S - T[a - 1] + b
	print(SS)


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


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


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)


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


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

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

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

def lint_dec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
N = ii()
T = lint()
M = ii()
total = sum(T)
for _ in range(M):
	(P, X) = lint()
	print(total - T[P - 1] + X)


n = int(input())
times = list(map(int, input().split()))
m = int(input())
drinks = []
for _ in range(m):
	drink = list(map(int, input().split()))
	drinks.append(drink)
for drink in drinks:
	time = 0
	copy = times.copy()
	copy[drink[0] - 1] = drink[1]
	for i in copy:
		time += i
	print(time)


N = int(input())
times = list(map(int, input().split()))
M = int(input())
drinks = []
for _ in range(M):
	drinks.append(list(map(int, input().split())))
for drink in drinks:
	total = 0
	for j in range(N):
		if drink[0] == j + 1:
			total += drink[1]
		else:
			total += times[j]
	print(total)


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):
	t_sum = X[i]
	for j in range(N):
		if j == P[i] - 1:
			continue
		t_sum += T[j]
	print(t_sum)


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


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


n = int(input())
l = [0] + list(map(int, input().split()))
ans = sum(l)
for i in range(int(input())):
	(a, s) = list(map(int, input().split()))
	print(ans - l[a] + s)


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


N = int(input())
T = list(map(int, input().split()))
M = int(input())
X = []
for i in range(M):
	X.append(list(map(int, input().split())))
	X[i][0] = X[i][0] - 1
Y = []
for i in range(N):
	Y.append(T[i])
for i in range(len(X)):
	Y_copy = Y.copy()
	Y_copy[X[i][0]] = X[i][1]
	print(sum(Y_copy))


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


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


N = int(input())
L = list(map(int, input().split()))
Q = int(input())
c = sum(L)
for i in range(Q):
	(a, b) = map(int, input().split())
	print(c - (L[a - 1] - b))


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


N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
	(A, B) = map(int, input().split())
	ans = sum(T) - T[A - 1] + B
	print(ans)


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


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


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


l = lambda : map(int, input().split())
l()
(*T,) = l()
(*M,) = l()
S = sum(T)
for (P, X) in [l() for _ in [0] * M[0]]:
	print(S - T[P - 1] + X)


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


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


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


(n, *t) = map(int, open(0).read().split())
for (p, x) in zip(t[n + 1::2], t[n + 2::2]):
	print(sum(t[:n]) - t[p - 1] + x)


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)


n = int(input())
t = list(map(int, input().split()))
y = 0
for l in t:
	y += l
for k in range(int(input())):
	(p, x) = map(int, input().split())
	print(y - t[p - 1] + x)


n = int(input())
(*pr,) = map(int, input().split())
for i in range(int(input())):
	(n, v) = map(int, input().split())
	print(sum(pr) - pr[n - 1] + v)


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


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


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


n = int(input())
data_1 = list(map(int, input().split()))
m = int(input())
data_2 = [input().split() for i in range(m)]
for i in range(m):
	sum = 0
	b = int(data_2[i][0]) - 1
	a = data_1[b]
	data_1[b] = int(data_2[i][1])
	for j in range(n):
		sum += data_1[j]
	print(sum)
	data_1[b] = a


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


N = int(input())
T = list(map(int, input().split()))
M = int(input())
L = []
for _ in range(M):
	(p, x) = list(map(int, input().split()))
	L.append([p, x])
for i in range(M):
	sum_num = 0
	for j in range(N):
		if L[i][0] - 1 == j:
			sum_num += L[i][1]
		else:
			sum_num += T[j]
	print(sum_num)


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


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


N = int(input())
T = list(map(int, input().split()))
M = int(input())
L = []
res = []
for i in range(M):
	(P, X) = list(map(int, input().split()))
	buf = []
	for j in range(len(T)):
		if P == j + 1:
			buf.append(X)
		else:
			buf.append(T[j])
	res.append(sum(buf))
for i in res:
	print(i)


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


n = int(input())
t_l = list(map(int, input().split()))
m = int(input())
import copy
for _ in range(m):
	(k, v) = map(int, input().split())
	tmp_t = copy.deepcopy(t_l)
	tmp_t[k - 1] = v
	print(sum(tmp_t))


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


_ = 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)


N = int(input())
(*T,) = map(int, input().split())
M = int(input())
PX = [list(map(int, input().split())) for _ in [0] * M]
S = sum(T)
for (P, X) in PX:
	print(S - T[P - 1] + X)


N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
	(Pi, Xi) = map(int, input().split())
	a = T[Pi - 1]
	T[Pi - 1] = Xi
	b = 0
	for j in range(N):
		b = b + T[j]
	print(b)
	T[Pi - 1] = a


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)


N = int(input())
T = list(map(int, input().split()))
M = int(input())
SUM = sum(T)
for _ in range(M):
	(i, j) = map(int, input().split())
	print(SUM - T[i - 1] + j)


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
n = ri()
t = rl()
sum_ = sum(t)
m = ri()
for _ in range(m):
	(p, x) = rm()
	p -= 1
	print(sum_ - t[p] + x)


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)


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


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


n = int(input())
t = list(map(int, input().split()))
m = int(input())
ans = [10 ** 10] * n
s = sum(t)
for i in range(m):
	(h, x) = map(int, input().split())
	print(s + x - t[h - 1])


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


a = int(input())
x = list(map(int, input().split()))
b = int(input())
for i in range(b):
	(ta, tb) = map(int, input().split())
	print(sum(x) + tb - x[ta - 1])


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


N = int(input())
T = input().split()
M = int(input())
for i in range(N):
	T[i] = int(T[i])
S = sum(T)
for i in range(M):
	l = input().split()
	print(S - (T[int(l[0]) - 1] - int(l[1])))


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


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


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


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


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


import copy
n = int(input())
T = list(map(int, input().split()))
m = int(input())
for _ in range(m):
	A = copy.copy(T)
	(a, b) = map(int, input().split())
	A[a - 1] = b
	print(sum(A))


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


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


n = int(input())
a = list(map(int, input().split()))
num_drink = int(input())
for i in range(num_drink):
	(P, X) = map(int, input().split())
	A = a.copy()
	A[P - 1] = X
	print(sum(A))


N = int(input())
T = [int(TN) for TN in input().split()]
SumT = sum(T)
M = int(input())
PX = [[] for TM in range(0, M)]
for TM in range(0, M):
	PX[TM] = [int(TPX) for TPX in input().split()]
for TM in range(0, M):
	print(SumT - T[PX[TM][0] - 1] + PX[TM][1])


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


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