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

import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)


def main():
    N=int(input())
    T=list(map(int,input().split()))
    M=int(input())
    ssum=sum(T)
    for a in range(M):
        p,x=map(int,input().split())
        p-=1
        sssum=ssum-T[p]+x
        print(sssum)
main()

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

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

M = int(input())

def readlines():
    for _ in range(M):
        p, x = map(int, input().split())
        yield p-1, x

px = list(readlines())

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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

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

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

Solution (Python):
N=int(input())
listA = list(map(int,input().split()))
R= int(input())
sum_n = sum(listA)
for i in range(R):
    listB = list(map(int,input().split()))
    print(sum_n-(listA[listB[0]-1]-listB[1]))

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




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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n=I()
Ts=LI()
m=I()
for i in range(m):
    a,b=MI()
    ans=sum(Ts)-Ts[a-1]+b
    print(ans)

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

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

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

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

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

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

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

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

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

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

total = sum(t)
for p, x in px:
    print(total-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 p,x in P:
    print(sum(t)-t[p-1]+x)

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

b_time=sum(t)
for i in range(0,m):
  toi=lis[i][0]
  after_time=lis[i][1]
  before_time=t[toi-1]
  sa=before_time-after_time
  print(b_time-sa)

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

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

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

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

Solution (Python):
from copy import deepcopy

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

for q in range(m):
    mt = deepcopy(t)
    p, x = map(int, input().split())
    mt[p - 1] = x
    print(sum(mt))

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

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



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

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

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

Solution (Python):
import copy
N = int(input())
lis = [int(x) for x in input().split()]
for j in range(int(input())):
    time = copy.deepcopy(lis)
    p, x = map(int, input().split())
    time[p-1] = x
    print(sum(time))

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

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

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):
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

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

M = int(input())

_all = sum(T)

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

    print(_all - T[p]+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)]

tmax=sum(t)

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

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

if '__main__' == __name__:
    resolve()

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

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

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)

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

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

def main():
    N = int(readline())
    T = list(map(int, readline().rstrip().split()))
    S = sum(T)
    M = int(readline())
    for _ in range(M):
        p, x = map(int, readline().rstrip().split())
        print(S - T[p-1] + x)


if __name__ == '__main__':
    main()

Solution (Python):

n = int(input()) 
lst = list(map(int,input().split())) 
d = int(input()) 

total_time = sum(lst)
ans = 0
for i in range(d):
    a,b = map(int,input().split()) 
    ans = total_time + b - lst[a - 1]
    print(ans)

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

p = []
x = []

while True:
  try:
    tp,tx = map(int,input().split())
    p.append(tp)
    x.append(tx)
    
  except:
    break
    
for i in range(m):
  T = copy(t)
  T[p[i]-1] = x[i]
  print(sum(T))

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

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

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

total = sum(T)

M = int(input())

PX = []
for i in range(M):
  p,x = map(int,input().split())
  PX.append((p,x))
  
for j in PX:
  print(total-T[j[0]-1]+j[1])

Solution (Python):


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

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

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

for j in range(M):
    print(lst[j])

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())
Alist = list(map(int, input().split())) 
M= int(input())
px = [list(map(int, input().split())) for _ in range(M)]
res = sum(Alist)
for i in range(0,M):
    out = res -Alist[px[i][0]-1] + px[i][1]
    print(out)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    T = list(map(int, input().split()))
    m = int(input())

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


if __name__ == '__main__':
    resolve()

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

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

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

Solution (Python):
n = int(input())    
A =  list(map(int,input().split()))
S = sum(A)
m = int(input())    
def pr():
    p,x = map(int,input().split())
    print(S-(A[p-1]-x))
for _ in range(m):
    pr()

Solution (Python):
import copy

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

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

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

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

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

for i in ans:
    print(i)

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

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

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

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

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

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

Solution (Python):
n = int(input())
T = list(map(int,input().split()))
m = int(input())
d = [list(map(int,input().split())) for _ in range(m)]
sumT = sum(T)
for b in d:
    print(sumT - (T[b[0]-1]-b[1]))

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7
INF = float('inf')

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




if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
t_inputs = [int(i) for i in input().split()]
m = int(input())
p_inputs = [[int(j) for j in input().split()]for i in range(m)]

neutral_sum = sum(t_inputs)

for i in range(m):
    drink_no = p_inputs[i][0]-1
    ans = neutral_sum-t_inputs[drink_no]+p_inputs[i][1]
    print(ans)

Solution (Python):
import copy

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

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):
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    t_sum = sum(T)
    ans = []
    for i in range(M):
        p, x = map(int, input().split())
        ans.append(t_sum - T[p - 1] + x)
    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
list_T = list(map(int, input().split()))
m = int(input())
list_PX = [ list(map(int,input().split(" "))) for i in range(m)]
sum_value = sum(list_T)
for i in range(m):
    l = list_PX[i]
    print(sum_value-(list_T[l[0]-1]-l[1]))

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

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

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

Solution (Python):
















N = int(input())
arrT = [0] + list(map(int,input().split()))
M = int(input())
PandX = [list(map(int,input().split())) for i in range(M)]

total = sum(arrT)
for pm in PandX:
    pnum ,x = pm[0],pm[1]
    print(total - arrT[pnum] + 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)]

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

Solution (Python):
import copy

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

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

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

sm = sum(T)

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

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

for i in range(m):
  temp = t.copy()
  p, x = px[i]
  temp[p-1] = x
  print(sum(temp))

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

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(x) for x in input().split()]

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

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

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

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

Solution (Python):
N = int(input())
T = input().split()
M = int(input())
P = [0] * M
X = [0] * M

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

solve_without = 0
solve_without = sum(int(T[a]) for a in range(N))

for ii in range(M):
    solve_with = solve_without - int(T[P[ii] - 1]) + X[ii]
    print(solve_with)

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

for a in ans:
  print(a)

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

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

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

Solution (Python):
n=int(input())
t=[0]*n
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())
  
al=sum(t)
for i in range(m):
  print(al-t[p[i]-1]+x[i])

Solution (Python):

import copy

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

for time in times:
    print(time)

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

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

m = int(input())
drink = []
for _ in range(m):
    p, x = map(int, input().split())
    drink.append((p, x))

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

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

Solution (Python):

def myAnswer(N:int,T:list,M:int,P:list,X:list)-> None:
   
   for i in range(M):
      print(sum(T) - T[P[i]-1] + X[i])

def modelAnswer():
   tmp=1
def main():
   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)
   myAnswer(N,T[:],M,P[:],X[:])

if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(N:int,T:list,M:int,P:list,X:list)-> None:
   all_time = sum(T)
   for i in range(M):
      print(all_time - T[P[i]-1] + X[i])

def modelAnswer():
   tmp=1
def main():
   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)
   myAnswer(N,T[:],M,P[:],X[:])

if __name__ == '__main__':
   main()

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

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

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

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

a = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    ans.append(a - 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())
PX = [list(map(int,input().split())) for i in range(M)]
tmp2 = 0
P = 0
X = 0
c = 0
for a in range(M):
  tmp = PX[a]
  for b in tmp:
    if(c == 0):
      P = b
      c += 1
    else:
      X = b
      c = 0
  tmp2 = T[P - 1]
  T[P - 1] = X
  print(sum(T))
  T[P - 1] = tmp2

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

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

ans_org = sum(T)

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

Solution (Python):
import io

nim=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())
fulltime=sum(t)
for i in range(m):
    print(fulltime-(t[p[i]-1]-x[i]))

Solution (Python):
N = int(input())
nums = [int(e) for e in input().split()]
M = int(input())
P = []
for i in range(0,M):
    P.append([int(t) for t in input().split()])
ans = 0
a = 0
for i in range(0,M):
    a = nums[P[i][0]-1]
    nums[P[i][0]-1] = P[i][1]
    for k in range(0,N):
        ans += nums[k]
    print(ans)
    ans = 0
    nums[P[i][0]-1] = a

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

anss = []
for i in p:
    ans = []
    pp , xx = map(int , i.split())
    for i , n in enumerate(t):
        if i+1 == pp:
            ans.append(xx)
        else:
            ans.append(n)
    anss.append(ans)
for i in anss:
    print(sum(i))

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

Solution (Python):
N = int(input())
T = [0] + [int(x) for x in input().split()]
M = int(input())
s = sum(T)
 
answer = []
for _ in range(M):
  a,b = map(int,input().split())
  answer.append(s+b-T[a])
 
print(*answer,sep='\n')

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

gokei = sum(T)

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