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

Submission status: Accepted

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

t = sum(T)

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

Submission status: Accepted

Solution code:
n,tt,m,*px = [list(map(int, s.split())) for s in open(0)]

stt = sum(tt)

for p,x in px:
    print(stt-tt[p-1]+x)

Submission status: Accepted

Solution code:
import copy

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

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

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

Submission status: Accepted

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

for m in range(M):
    tmp_T = T[:]
    tmp_T[D[m][0]-1] = D[m][1]
    print(sum(tmp_T))

Submission status: Accepted

Solution code:
import copy
N = int(input())
MM = input().split()
M = int(input())
for i in range(M):
  cc = copy.copy(MM)
  total = 0
  
  aa = input().split()
  a = int(aa[0])
  b = int(aa[1])
  cc[a-1] = b
  for j in cc:
    total += int(j)
  print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    ans = []
    for _ in range(M):
        P, X = map(int, input().split())
        ans.append(str(sum(T) - T[P - 1] + X))
    print("\n".join(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
n = int(s)

questions = []
copy = []
answer = 0

x = input().split()

for num in range(len(x)):
    questions.append(x[num])
    copy.append(x[num])

v = input()
m = int(v)

for num in range(m):
    d = input().split()
    questions[int(d[0]) - 1] = int(d[1])
    for y in range(len(questions)):
        answer += int(questions[y])
    print(answer)
    answer = 0
    for z in range(len(questions)):
        questions[z] = copy[z]

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 = list(map(int, input().split()))
s = sum(T)
M = int(input())
res = [0] * M
for i in range(M):
    p, x = map(int, input().split())
    res[i] = s - T[p-1] + x
print(*res, sep='\n')

Submission status: Accepted

Solution code:
import copy

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

Submission status: Accepted

Solution code:
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):
    time = [x for x in t]
    time[p[i][0] - 1] = p[i][1]
    print(sum(time))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
t = sum(T)
M = int(input())
S = [list(map(int, input().split())) for _ in range(M)]
for s in S:
    print(t - T[s[0] - 1] + s[1])

Submission status: Accepted

Solution code:
from sys import stdin

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

sum_t = sum(t)

ans = []
for _ in range(m):
    p, x = map(int, stdin.readline().strip().split())
    ans.append(sum_t - t[p-1] + x)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
T = ri_()
M = ri()
wa = sum(T)
for _ in range(M):
    P, X = ri_()
    ans = wa + X - T[P - 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)]
for p in P:
    tmp_l = T.copy()
    tmp_l[p[0]-1] = p[1]
    print(sum(tmp_l))

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
t = sum(T)
M = int(input())
S = [list(map(int, input().split())) for _ in range(M)]
for s in S:
    print(t - T[s[0] - 1] + s[1])

Submission status: Accepted

Solution code:
n=int(input())
lst=[]

tup = tuple(map(int,input().split()))




m=int(input())

for i in range(m):
    prev,nxt=input().split()
    prev=int(prev)
    nxt=int(nxt)
    lst=list(tup)
    res = 0
    lst[prev-1]=nxt
    for i in range(n):
        res=res+lst[i]
    print(res)

Submission status: Accepted

Solution code:
n = int(input())
lt = [int(w) for w in input().split()]
m = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
Ts = list(map(int,input().split()))
M = int(input())
Ps =[list(map(int,input().split())) for i in range(M)]
s = sum(Ts)
for i in range(M):
  index = Ps[i][0]-1
  diff = Ps[i][1] - Ts[index]
  print(s+diff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(n, ), t, (m, ), *d = [[*map(int, i.split())] for i in open(0)]
s = sum(t)
for p, x in d:
    print(s - t[p - 1] + x)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

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):
    a, b = map(int, input().split())
    print(ans-t[a-1]+b)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

#print(T,D)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

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

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    T = list(mi())
    M = ii()
    P, X = i2(M)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	t_list = LI()
	m = I()
	px_list = LIR(m)

	original_time = sum(t_list)
	for p, x in px_list:
		print(original_time - t_list[p-1] + x, end='\r\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    t = Intl()
    m = I()
    px = [Intl() for i in range(m)]
    s = sum(t)
    ps = s
    for i in range(m):
        a,b = px[i][0],px[i][1]
        s -= t[a-1]
        s += b
        print(s)
        s -= b
        s += t[a-1]

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
t = intl()
m = i()
p = []
x = []
for i in range(m):
	P,X = i2()
	p.append(P)
	x.append(X)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(m):
    t = T.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())

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

Submission status: Accepted

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

Submission status: Accepted

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

time = sum(t_li)

for i, j in d_li:
    print(time - t_li[i-1] + j)

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())
  time=0
  for j in range(n):
    if j==p-1:
      time+=x
    else:
      time+=t[j]
  print(time)

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().rstrip().split(" ")))
time = 0
for i in T:
    time += i
M = int(input())
for _ in range(M):
    P,X = map(int,input().rstrip().split(" "))
    print(X - T[P - 1] + time)

Submission status: Accepted

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

Submission status: Accepted

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

t_sum = sum(T)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

for i in range(m):
    t_l_i = list(t_l)
    p, x = map(int, input().split())
    t_l_i[p - 1] = x
    result.append(sum(t_l_i))

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

Submission status: Accepted

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

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

S  = sum(T)
for p, x in PX:
    print(S - 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())
  res = t[p-1] -x
  print(sum(t) - res)

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    T = read_ints()
    M = read_int()
    S = sum(T)
    for _ in range(M):
        p, x = read_ints()
        print(S-T[p-1]+x)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
t=[0]+[int(x) for x in input().split()]
m=int(input())
for _ in range(m):
    x,y=map(int,input().split())
    tt=t[:]
    tt[x]=y
    print(sum(tt))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def getlistofstring(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.setrecursionlimit(10**6)
# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
n = int(input())
li = get_list()
s = sum(li)
for _ in range(int(input())):
    ind, val = get_ints()
    print(s - li[ind-1] + val)

'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def INT():
    return int(input())

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

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

N = INT()
T = LI()
M = INT()

ans = sum(T)

for i in range(M):
    tmp = ans
    P, X = MI()
    tmp = tmp - T[P - 1] + X
    print(tmp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sum = sum(t)

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

Submission status: Accepted

Solution code:
n=int(input())
ti=list(map(int,input().split()))
m=int(input())
p=[]
x=[]
for i in range(m):
  pn,xn=map(int,input().split())
  p.append(pn)
  x.append(xn)
tsum=sum(ti)
for i in range(m):
  sa=ti[p[i]-1]-x[i]
  print(tsum-sa)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
question_num = int(input())
Time = list(map(int, input().split()))
drink_num = int(input())
spent_time = sum(Time)
drink =[]
for _ in range(drink_num):
    p, x = map(int, input().split())
    print(spent_time - (Time[p - 1] - x))

Submission status: Accepted

Solution code:
question_num = int(input())
Time = list(map(int, input().split()))
drink_num = int(input())
spent_time = sum(Time)
drink =[]
for _ in range(drink_num):
    p, x = map(int, input().split())
    drink.append([p, x])
for p, x in drink:
    print(spent_time - (Time[p - 1] - x))

Submission status: Accepted

Solution code:
import copy

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    return

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[4]:


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list_n = list(map(int, input().split()))
M = int(input())
list_m = [[int(i) for i in input().split()] for j in range(M)]

for i in range(M):
    x, y = list_m[i][0], list_m[i][1]
    a = list_n[x-1]
    sum_a = sum(list_n)
    print(sum_a - (a-y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
drag = [list(map(int, input().split())) for n in range(M)]
for d in drag:
    print(sum(T) - T[d[0] - 1] + d[1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n = readInt()
t = readInts()
m = readInt()
px = []
for i in range(m):
	px.append(readInts())
sumTime = sum(t)

for i in range(m):
	print(sumTime-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())

zenbu = sum(T)

for _ in range(M):
    P, X = map(int, input().split())
    print(zenbu - 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()))
m=int(input())
sumt=sum(t)

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

Submission status: Accepted

Solution code:
n = int(input())
times = list(map(int, input().split()))
total = sum(times)
m = int(input())
for _ in range(m):
    index, newTime = map(int, input().split())
    print(total - times[index - 1] + newTime)

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)]
a = sum(t)
for i,j in p:
    print(a-t[i-1]+j)

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())
time=sum(t)
for i in range(m):
  p,x=map(int,input().split())
  print(time-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 _ in range(m)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def abc050_b():
    _ = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    Query = [tuple(map(int, input().split())) for _ in range(M)]

    tot = sum(T)
    for p, x in Query:
        ans = tot - T[p-1] + x
        print(ans)

abc050_b()

Submission status: Accepted

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

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):
    test = []
    for j in range(N):
        test.append(T[j])
    test[PX[i][0]-1] = PX[i][1]
    print(sum(test))