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



Sample input:
3
2 1 4
2
1 1
2 3


Sample output:
6
9

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = int(input())
drink_list = []

for i in range(t):
    array = list(map(int, input().split()))
    drink_list.append(array)

for i in range(t):
    b = a.copy()
    b[drink_list[i][0]-1] = drink_list[i][1]
    print(sum(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
A=[]
for i in range(M):
    u=list(map(int,input().split()))
    A.append(u)

import copy
for i in range(M):
    UU=copy.deepcopy(T)
    UU[A[i][0]-1]=A[i][1]
    print(sum(UU))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
from copy import deepcopy

n = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

for i in li:
    lin = deepcopy(t)
    lin[i[0]-1] = i[1]
    print(sum(lin))

Submission status: Accepted

Solution code:
n = int(input())
T = list(map(int, input().split()))
m = int(input())
drink_list=[]
sum_list = []
for i in range(m):
    drink_list.append(list(map(int, input().split())))    
for i in range(m):
    #元の値を保存しておく
    a = T[drink_list[i][0]-1] 
    T[drink_list[i][0]-1] = drink_list[i][1]
    print(sum(T))
    T[drink_list[i][0]-1] = a

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
while cnt < M:
    P, X = map(int, input().split())

    ans = 0
    P -= 1
    for i in range(len(T)):
        if i == P: 
            ans += X
        else:
            ans += T[i]
    print(ans)
    cnt += 1

Submission status: Accepted

Solution code:
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
d = [[int(i) for i in input().split()] for _ in range(m)]
for i in range(m):
  p, x = d[i]
  print(sum(x if j + 1 == p else t[j] for j in range(n)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
##### 解けた #####

N=int(input()) # 問題の数
T=list(map(int,input().split(" "))) # 問題を解くのにかかる時間
M=int(input()) # ドリンクの数
Tsum=sum(T) # 何も飲まない場合の合計時間

# 各ドリンクについて
for _ in range(M):
    p,x=list(map(int,input().split(" ")))
    print(Tsum-(T[p-1]-x)) # 該当するドリンクを飲んだ場合の合計時間

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    T=LI()
    M=I()
    PX=LLIN(M)
    ans = sum(T)
    for i,(p,x) in enumerate(PX):
        print(ans - (T[p-1] - x))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

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

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[px_li[j][0] - 1] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)

Submission status: Accepted

Solution code:
n = int(input())
T = list(map(int,input().split()))
m = int(input())
PX = [list(map(int,input().split())) for i in range(m)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
for i in range(M):
    p,x = map(int,input().split())
    P.append([p,x])
ans = sum(T)
for i in P:
    X = copy.copy(T)
    X[i[0]-1] = i[1]
    ans = sum(X)
    print(ans)

Submission status: Accepted

Solution code:
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):
    t =  T.copy()
    t[px[i][0]-1] = px[i][1]
    print(sum(t))

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int, input().split()))
total = sum(t)
m = int (input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#テストファイルで実行する時
import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

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

#print(p)
#print(p[0][0])
#print(p[1][1])

#リストのコピーをするとき 
import copy

for i in range(m):
	test = copy.copy(t)#リストのコピー
	test[p[i][0]-1] = p[i][1]
	#print(t)
	#print(test)
	print(sum(test))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    T=list(map(int,input().split()))
    s=sum(T)
    m=int(input())
    PX=[tuple(map(int,input().split())) for _ in range(m)]
    for i in range(m):
        p,x=PX[i]
        p-=1
        print(s-T[p]+x)
resolve()

Submission status: Accepted

Solution code:
from collections import deque


def solve():
    N = int(input())
    Ti = tuple(map(int, input().split()))
    M = int(input())

    PXi = deque()
    for _ in range(M):
        PXi.append(tuple(map(int, input().split())))

    # print(N)
    # print(Ti)
    # print(M)
    # print(PXi)

    total = sum(Ti)

    ans = deque()
    for p, x in PXi:
        p -= 1
        before = Ti[p]
        after = x

        if before <= after:
            ans.append(total + abs(before - after))
        else:
            ans.append(total - abs(before - after))

    return ans


if __name__ == '__main__':
    res = solve()
    for r in res:
        print(r)

Submission status: Accepted

Solution code:
N = int(input())
T = [int(a) for a in input().split()]
M = int(input())
X = [[int(a) for a in input().split()] for _ in range(M)]
s = sum(T)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
T = list(map(int, input().split()))
tt = T.copy()
m = int(input())

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

Submission status: Accepted

Solution code:
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+x-T[p-1])

Submission status: Accepted

Solution code:
#!python3.4.3

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

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

Submission status: Accepted

Solution code:
#!python3.4.3

n = int(input())
t = list(map(int, 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))

Submission status: Accepted

Solution code:
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())
    t = T[P-1] - X
    print(ans-t)

Submission status: Accepted

Solution code:
import copy
n=int(input())
t=[int(i) for i in input().split()]
m=int(input())
for i in range(m):
    cur=copy.deepcopy(t)
    drink=[int(i) for i in input().split()]
    cur[drink[0]-1]=drink[1]
    print(sum(cur))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

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

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

Submission status: Accepted

Solution code:
n = int(input())

l = [int(i) for i in input().split()]
total = sum(l)

m = int(input())

drink = [[int(i) for i in input().split()] for _ in range(m)]

for i in drink:
    print(total + (i[1] - l[i[0]-1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Contest with Drinks Easy
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0 for i in range(M)]
X = [0 for i in range(M)]
for i in range(M):
    P[i], X[i] = map(int, input().split())
for i in range(M):
    t = 0
    for j in range(N):
        if j+1 == P[i]:
            t = t + X[i]
        else:
            t = t + T[j]
    print(t)

Submission status: Accepted

Solution code:
# python3 (3.4.3)
import sys
input = sys.stdin.readline

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

total = sum(T)

Ans = []
for p,x in PX:
    Ans.append(total - T[p-1] + x)

for ans in Ans:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examB():
    N = I()
    T = LI()
    totalT = sum(T)
    M = I()
    ans = []
    for i in range(M):
        P, X =LI()
        ans.append(totalT + X - T[P-1])
    for v in ans:
        print(v)



import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

Solution code:
N=int(input())
Q=list(map(int, input().split()))
M=int(input())
D = [list(map(int, input().split())) for i in range(M)]
for i in D:
    a=Q[i[0]-1]
    Q[i[0]-1]=i[1]
    print(sum(Q))
    Q[i[0]-1]=a

Submission status: Accepted

Solution code:
# ABC 050: B – Contest with Drinks Easy
n = int(input())
t = [int(s) for s in input().split()]
m = int(input())

p = []
x = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    t = inpl()
    m = inp()
    px = [inpl() for i in range(m)]
    for i in px:
        print(sum(t) - t[i[0]-1] + i[1])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [ list(map(int,input().split())) for _ in range(m) ]
import copy as c
for i in range(m):
    tmp = c.copy(t)
    tmp[px[i][0]-1] = px[i][1]
    print(sum(tmp))

Submission status: Accepted

Solution code:
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())
  print(s-(t[p-1]-x))

Submission status: Accepted

Solution code:
N=int(input())
T=[0];T.extend(list(map(int,input().split())))
M=int(input())
Tsum=sum(T)
for i in range(M):
    P,X=map(int,input().split())
    print(Tsum-T[P]+X)

Submission status: Accepted

Solution code:
A = int(input())
T = list(map(int,input().split()))
D = int(input())
defo = []
for _ in range(D):
  defo = T
  a,p = map(int,input().split())
  q = T[a-1] -p
  s = sum(defo)
  s = s-q
  print(s)

Submission status: Accepted

Solution code:
n=int(input())

s=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=s[i]
  
  
m=int(input())

ans=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = [int(i) for i in input().split()]
m = int(input())
LL = []
for i in range(m):
  LL.append([int(i) for i in input().split()])

for i in range(m):
  LLL = list(L)
  LLL[LL[i][0]-1] = LL[i][1]
  print(sum(LLL))

Submission status: Accepted

Solution code:
n = int(input())
problems = list(map(int, input().split()))

d = int(input())

for i in range(d):
  p, x = map(int, input().split())
  copied = problems[:]
  copied[p - 1] = x
  print(sum(copied))

Submission status: Accepted

Solution code:
n = int(input())
T = input().split()
t = [int(s) for s in T] #リストの文字をintに変換
t_sum = 0
for i in range(len(t)):
    t_sum = t_sum + t[i]
m = int(input())
PX = []
for i in range(m):
    PX.extend(input().split())
px = [int(s) for s in PX]
for j in range(0,2*m-1,2):
    print(t_sum - t[(px[j]-1)] + px[j+1])

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
mat = [list(map(int,input().split())) for i in range(M)]
ans = [0]*M
time = sum(T)
for i in range(M):
    ans[i] = time-T[mat[i][0]-1]+mat[i][1]
for j in range(len(ans)):
    print(ans[j])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
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)

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
T.insert(0,0)
tot = sum(T)
M = int(input())
for _ in range(M):
    P,X = map(int,input().split())
    print(tot-T[P]+X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [int(t) for t in input().split()]

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

Submission status: Accepted

Solution code:
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):
    id = px[i][0]-1
    if id >= 1:
        print(sum(T[:id]) + sum(T[id+1:]) + px[i][1])
    else:
        print(sum(T[id+1:])+px[i][1])

Submission status: Accepted

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
l=[list(map(int, input().split())) for i in range(m)]
#print(l)

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

Submission status: Accepted

Solution code:
def main():
  n = int(raw_input())
  tasks = map(int, raw_input().split())
  m = int(raw_input())
  for _ in xrange(m):
    p, x = map(int, raw_input().split())
    total_time = sum(tasks) - tasks[p-1] + x
    print(total_time)

main()

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int, input().split()))
M = int(input())
for _ in range(M):
    P, X = map(int, input().split())
    l = lst[0 : P - 1] + lst[P:]
    print(sum(l) + X)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(map(int,input().split()))

ttl = sum(l)

m = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P1 = range(M)
P = list(P1)
X1 = range(M)
X = list(X1)
for i in range(0,M):
    P[i],X[i] = map(int,input().split())
    moto = T[P[i]-1]
    T[P[i]-1] = X[i]
    print(sum(T))
    T[P[i]-1] = moto

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
A = list(map(int, input().strip().split(' ')))
A_sum = sum(A)
M = int(input().strip())
for _ in range(M):
  p,x = map(int, input().strip().split(' '))
  print(A_sum-A[p-1]+x)

Submission status: Accepted

Solution code:
N = int(input())
T = input().split()
M = int(input())

Drink = []
for D in range(M):
    Drink.append(input().split()) 
    
#print(Drink)

AnsTime = 0
for t in range(N):
    AnsTime += int(T[t]) 
#print(AnsTime)
#print(T[0])
#print(Drink[0][0])
#print(T[int(Drink[0][0])])
for Dec in range(M):
    DecreaseTime = AnsTime - (int(T[int(Drink[Dec][0])-1]) - int(Drink[Dec][1]) )
    print(DecreaseTime)

Submission status: Accepted

Solution code:
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) + x - T[p - 1])

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [list(map(int,input().split())) for _ in range(M)]
Sum = sum(T)
for i in range(M):
  if PX[i][1] > T[PX[i][0]-1]:
    print(Sum + PX[i][1] - T[PX[i][0]-1])
  else:
    print(Sum - (T[PX[i][0]-1] - PX[i][1]))

Submission status: Accepted

Solution code:
n = input()
t1 = list(map(int, input().split()))
m = int(input())
a = []
for i in range(m):
    t2 = t1.copy()
    p, x = map(int, input().split())
    t2[p - 1] = x
    a.append(sum(t2))
for i in range(len(a)):
    print(a[i])

Submission status: Accepted

Solution code:
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = [[int(x) for x in input().split()] for i in range(M)]
for i in range(len(PX)):
  R = T[PX[i][0]-1]
  T[PX[i][0]-1] = PX[i][1]
  print(sum(T))
  T[PX[i][0]-1] = R

Submission status: Accepted

Solution code:
from functools import reduce

if __name__ == "__main__":
    n = int(input())
    t = [int(x) for x in input().split()]
    m = int(input())
    improvements = []
    for i in range(m):
        drink = list(map(int, input().split()))
        tmp = t[drink[0] - 1]
        t[drink[0] - 1] = drink[1]
        improvements.append(reduce(lambda x, y: x + y, t))
        t[drink[0] - 1] = tmp
    for el in improvements:
        print(el)

Submission status: Accepted

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


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

Submission status: Accepted

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

n_s = sum(T)
for m in P:
    print(n_s - (T[m[0]-1] - m[1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
s = sum(T)
M = int(input())
for i in range(M):
    pi, xi = map(int, input().split())
    tmp = s + xi - T[pi-1]
    print(tmp)

Submission status: Accepted

Solution code:
def resolve():
    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())
        print(s-t[p-1]+x)

resolve()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n = int(input())

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

m = int(input())

original = sum(time)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Ps = list(map(int,input().split(" ")))
s = sum(Ps)
m = int(input())
for  _ in range(m):
  i,v = list(map(int,input().split(" ")))
  print(s - Ps[i-1] + v)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
for i in range(M):
  P, x = map(int, input().split())
  Ts_2 = copy.copy(Ts) #コピーを行う
  Ts_2[P-1] = x
  print(sum(Ts_2))

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    t = list(map(int, input().rstrip('\n').split()))
    m = int(input().rstrip('\n'))
    px = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    st = sum(t)
    for p, x in px:
        print(st - t[p-1] + x)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
PX = [list(map(int,input().split())) for _ in range(M)]
for px in PX:
    print(sum(Ts) - Ts[px[0]-1] + px[1])

Submission status: Accepted

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

X = [PX[i][1] for i in range(M)]
for px in PX:
    print(sum(Ts) - Ts[px[0]-1] + px[1])

Submission status: Accepted

Solution code:
input()
t=list(map(int,input().split()))
m=int(input())
p=[];x=[]
for _ in range(m):
    P,X=map(int,input().split())
    p.append(P)
    x.append(X)
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])