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_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 sys
input = sys.stdin.readline
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
li = [0] * M
for i in range(M) :
    li[i] = [int(i) for i in input().split()]
ans = [0] * M
sum = 0
for i in range(N) :
    sum += T[i]
for i in range(M) :
    k = sum - T[li[i][0] - 1] + li[i][1]
    ans[i] = k
for i in range(M) :
    print(ans[i])

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

sum = 0

for i in range(len(P)):
    t = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    for j in T:
        sum += j
    print(sum)
    sum = 0
    T[P[i][0] - 1] = t

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


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

Solution (Python):
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 9 + 7

N = int(readline())
T = list(map(int, readline().split()))
M = int(readline())

num = sum(T)
for _ in range(M):
    P, X = map(int, readline().split())
    print(num + X - T[P - 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):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
T=many_int()

M=one_int()

for i in range(M):
    P,X=two_int()
    temp = T[P-1]
    T[P-1] =X
    print(sum(T))
    T[P-1] = temp

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

ans = sum(t)
m = int(input())

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()))
M = int(input())
PX = [tuple(map(int, input().split())) for _ in range(M)]
st = sum(T)
for p, x in PX:
    print(st-T[p-1]+x)

Solution (Python):

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

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

Solution (Python):
def solve(n, T, m, PX):
    return [sum(x if i + 1 == p else t for i, t in enumerate(T)) for (p, x) in PX]

_n = int(input())
_T = list(map(int, input().split()))
_m = int(input())
_PX = [map(int, input().split()) for _ in range(_m)]
print(*solve(_n, _T, _m, _PX), sep='\n')

Solution (Python):
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)

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

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

total_time = sum(times) 

for i in range(m):
    time = times[drinks[i][0]-1]
    result = total_time - time + drinks[i][1]
    print(result)

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

for p, x in px:
    total = 0

    for i in range(N):
        if i + 1 == p:
            total += x
        else:
            total += T[i]

    print(total)

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

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

M = int(input(), 10)
answers = []
for _ in range(M):
    problem, become_time = tuple(map(int, input().split()))
    answer_elem = times[:]
    answer_elem[problem-1] = become_time
    answers.append(answer_elem)

for ans in answers:
    print(sum(ans))

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

for i in range(m):
    arr = list()
    for j in range(n):
        if p[i] == j+1:
            arr.append(x[i])
        else:
            arr.append(t[j])
    print(sum(arr))

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
all=int(0)
for i in range(n):
    all+=A[i]

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

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


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

N = int(input())
T = input().split()
M = int(input())

for j in range(M):
    P, X = map(int, input().split())
    Plist.append(P)
    Xlist.append(X)
    
for k in range(M):
    for l in range(len(T)):
        a = int(T[l])
        boxlist.append(a)
    
    num = Plist[k] -1
    
    boxlist[num] = Xlist[k]
    
    for j in range(len(boxlist)):
        ans = ans + boxlist[j]

    print(ans)
    ans = 0
    boxlist.clear()

Solution (Python):
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 p, x in PX:
  ans = total - T[p-1] + x
  print(ans)

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, T: "List[int]", M: int, P: "List[int]", X: "List[int]"):
    tot = sum(T)
    for i in range(M):
        print(tot-T[P[i]-1]+X[i])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    T = [int(next(tokens)) for _ in range(N)]  
    M = int(next(tokens))  
    P = [int()] * (M)  
    X = [int()] * (M)  
    for i in range(M):
        P[i] = int(next(tokens))
        X[i] = int(next(tokens))
    solve(N, T, M, P, X)


if __name__ == '__main__':
    main()

Solution (Python):
import copy
n = int(input())
t = [int(i) for i in 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):
import copy
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
for _ in range(m):
  p, x = map(int, input().split())
  t_copy = copy.deepcopy(t)
  t_copy[p-1] = x
  print(sum(t_copy))

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

lst = t.copy()

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    T = LIST()
    M = INT()
    L = [LIST() for i in range(M)]
    ans = []
    for i in range(M):
        T_copy = deepcopy(T)
        p = L[i][0]
        x = L[i][1]
        T_copy[p-1] = x
        print(sum(T_copy))






if __name__ == "__main__":
    main()

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

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

    print(total)

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

for Pi, Xi in PX:
    d = Xi - T[Pi - 1]
    print(sum(T) + d)

Solution (Python):


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

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

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

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

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

a=sum(t)
for i in range(m):
    j=d[i][0]
    ans=a-t[j-1]+d[i][1]

    print(ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ts=LIST()
    m=INT()
    xs=[0]*m
    for i in range(m):
        p,x=INTM()
        xs[i]=ts[p-1]-x
    tst=sum(ts)
    for i in range(m):
        
        print(tst-xs[i])
    
if __name__ == '__main__':
    do()

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

point = []
for i in range(M):
  a = sum(T) - T[PX[i][0] - 1] + PX[i][1]
  point.append(a)

for j in point:
  print(j)

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

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
Sum=sum(t)
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())
p = [list(map(int,input().split())) for _ in range(m)]


for g, h in p:
	ti = t.copy()
	ti[g-1] = h
	print(sum(ti))

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

Solution (Python):


n = int(input())
tlist = list(map(int, input().split()))
m = int(input())
mlist = []
for i in range(m):
  p_x = list(map(int, input().split()))
  mlist.append(p_x)

base = 0
for i in tlist:
  base = base + i

for p_x in mlist:
  p, x = p_x
  s = x - tlist[p-1]
  print(base + s)

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

Solution (Python):
from sys import stdin

sr = lambda: stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
T = lr()
M = ir()
total = sum(T)
for _ in range(M):
    p, x = lr()
    result = total - T[p-1] + x
    print(result)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
times = [int(i) for i in input().split()]
M = int(input())
p_x_list = [[int(i) for i in input().split()] for _ in range(M)]

for i, p_x in enumerate(p_x_list):
    p = p_x[0]
    x = p_x[1]
    
    print(sum(times) - times[p-1] + x)

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

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

for a in ans:
    print(a)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = []
for _ in range(M):
    PX.append([int(x) for x in input().split()])
total = sum(T)
ans = []
for i in range(M):
    P, X = PX[i]
    temp = total - T[P - 1] + X
    ans.append(temp)
for j in ans:
    print(j)

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

sum_t = sum(T)
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)]

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

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

Solution (Python):
import copy

n = int(input())

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

m = int(input())

pList = []
for i in range(m):
  pList.append(list(map(int,input().split())))

tpList =  copy.copy(tList)
for j in pList:
  tpList[j[0]-1]=j[1]
  print(sum(tpList))
  tpList = copy.copy(tList)

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

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

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

t_total = sum(t)

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

Solution (Python):

N = int(input())
T_list = [int(e) for e in 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):
N = int(input())
A = list(map(int, input().split()))
M = int(input())
total = sum(A)
ans = []
for _ in range(M):
  p, x = map(int, input().split())
  ans.append(total+x - A[p-1])
for a in ans:
  print(a)

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

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

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

Solution (Python):
n = int(input())
T = 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)

tot = sum(T)
for i in range(m):
    ans = tot - T[P[i]-1] + X[i]
    print(ans)

Solution (Python):


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

for drink in range(m):
    id = p[drink]
    
    ans = 0
    for i in range(n):
        if i+1 == id:
            ans += x[drink]
        else:
            ans += t[i]
    print(ans)

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

times_sum = sum(times)

for p, t in drinks:
    print(times_sum - times[p-1] + t)

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

for p, t in drinks:
    time = times.copy()
    time[p-1] = t
    print(sum(time))

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

drink=[]
for _ in range(m):
    a,b=map(int,input().split())
    drink.append(s + b -li[a-1])

print(*drink,sep='\n')

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

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

for x 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())
T=list(map(int,input().split()))
M=int(input())

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

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

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

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

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

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

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

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

Solution (Python):
import copy

n = int(input())
t = [int(i) for i in input().split()]

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

tmp = [print(i) for i in ans]

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

Solution (Python):
import copy


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

M = int(input())

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


for i in range(M):
    sum = 0
    P,X = A[i][0],A[i][1]
    P = P-1
    for j in range(N):
        if P!=j:
            sum = sum + T[j]
        else:
            sum = sum + X
    print(sum)

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

for i in range(m):
  ans=0
  for j in range(1,n+1):
    if j==dl[i][0]:
      ans+=dl[i][1]
    else:
      ans+=pl[j-1]
  print(ans)

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+1 == p:
      ans += x
    else:
      ans += T[j]
  print(ans)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
M = int(input())
ans = []
for i in range(M):
  p, x = map(int, input().split())
  copy_A = A.copy()
  copy_A[p-1] = x
  ans.append(sum(copy_A))
for a in ans:
  print(a)

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

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

Solution (Python):
n=int(input())
l=input().rstrip().split()
m=int(input())
ans=[]
A=0
for i in range(m):
    p,x=[int(i) for i in input().rstrip().split()]
    for j in range(len(l)):
        if p-1==j:
            A+=x
        else:
            A+=int(l[j])
    ans.append(A)
    A=0

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

Solution (Python):
n=int(input())
ti=input().split(' ')
times=[]
for i in ti:
    times.append(int(i))
summ=sum(times)
nu=int(input())
for i in range(0,nu):
    inps=input().split(' ')
    tempsum=summ
    tempsum=tempsum-times[int(inps[0])-1]
    tempsum+=int(inps[1])
    print(tempsum)

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

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

M = int(input())
for _ in range(M):
    i, x = map(int, input().split())
    ans = sum_all - T[i - 1] + x
    print(str(ans))

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

T_SUM = sum(T)
for a in A:
	print(T_SUM-a)

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

for i in range(m):
    s=[]
    for j in range(n):
        s.append(t[j])
    s[p[i]-1] = x[i]
    print(sum(s))

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

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

n=int(input())
t=list(map(int,input().split()))
m=int(input())
drinks=list(list(map(int, input().split())) for _ in range(m))

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

Solution (Python):
import sys

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

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

for i in ans:
    print(i)

Solution (Python):
from fractions import gcd

from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7



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

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


if __name__ == '__main__':
    main()

Solution (Python):

import copy

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

l = []

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


    print(sum(l))

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

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

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

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

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())
sum = sum(T)

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

Solution (Python):

import sys
import itertools
import math

i=0
N=int(input())




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





T_dummy_list=[]
pixel_list=[]
total=0
t=0












i=0
j=0







for i in range(M):
 total=0
 T_dummy_list[:]=T_list[:]
 T_dummy_list[drink_list[i][0]-1]=drink_list[i][1]
 
 for j in range(N):
    
    t=T_dummy_list[j]
    total=total+t

 print(total)

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

Solution (Python):
import sys
import numpy as np 

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n = I[0]
t = I[1:1+n]
m = I[1+n]
p, x = I[2+n:].reshape(m, 2).T 

def main():
    default = np.sum(t)
    res = default + (x - t[p-1])
    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

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

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

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

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

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

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

time = sum(ls_t)

for i in range(m):
    p = ls_px[i][0] - 1
    x = ls_px[i][1]
    print(time - ls_t[p] + x)

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

def swap(p,x):
  temp = list(T)
  temp[p - 1] = x
  return temp
for i in range(m):
  p,x = drinks[i][0],drinks[i][1]
  new = swap(p,x)
  ans_list.append(sum(new))
for ans in ans_list:
  print(ans)

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

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

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

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

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

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

output=[]
for j in range(M):
    tmp=T.copy()
    tmp[P[j]-1]=X[j]
    output.append(str(sum(tmp)))

print('\n'.join(output))

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