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(" ")))
s=sum(T)
M=int(input())
P=[]
for z in range(M):
  P.append(list(map(int,input().split(" "))))

for z in P:
  print(s-T[z[0]-1]+z[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
sumt = sum(T)
M = int(input())
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())
P, X = [], []
for i in range(M):
    _p, _x = map(int, input().split())
    P.append(_p)
    X.append(_x)

sm = sum(T)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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):
    time = 0
    ls = PX[i]
    for j in range(N):
        if ls[0] == j+1:
            time += ls[1]
        else:
            time += T[j]
    print(time)

Submission status: Accepted

Solution code:
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]

N=int(input())
T=ipt()
M=int(input())
PX=ipt(M)

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

Submission status: Accepted

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

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 _ in range(M)]

ans0 = sum(T)
for i in PX:
    print(ans0-T[i[0]-1]+i[1])

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

Submission status: Accepted

Solution code:
def getlist():
  return list(map(int, input().split()))

n = int(input())
times = getlist()
ans = sum(times)
k = int(input())
for i in range(k):
  a,b = getlist()
  print(ans - times[a-1] + b)

Submission status: Accepted

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

Submission status: Accepted

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

def solve(N, T, M, P, X):
    for i in range(M):
        print(sum(T) - T[P[i]] + X[i])

if __name__ == '__main__': 
    N = int(input())
    T = [int(t) for t in input().split()]
    M = int(input())
    P, X = [], []
    for i in range(M):
        p, x = map(int, input().split())
        P.append(p-1)
        X.append(x)

    solve(N, T, M, P, X)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
T = [int(i) for i in input().split()]
m = int(input())
s = sum(T)
for _ in range(m):
    p, x = [int(i) for i in 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())
px = [list(map(int, input().split())) for _ in range(m)]

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

Submission status: Accepted

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

for i in range(M):
    print(X[i])

Submission status: Accepted

Solution code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
P=[]
X=[]
for k in range(M):
    p,x=map(int,input().split())
    P.append(p)
    X.append(x)

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

Submission status: Accepted

Solution code:
import copy

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


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
N = int(input())
T = list(map(int, input().split()))
copy_T = copy.deepcopy(T)
M = int(input())
P_list = []
X_list = []
lists = []
for i in range(M):
    P, X = map(int, input().split())
    P_list.append(P)
    X_list.append(X)
for i in range(M):
    copy_T = copy.deepcopy(T)
    tmp = P_list[i]
    copy_T[tmp - 1] = X_list[i]
    print(sum(copy_T))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
t=list(map(int, input().split()))
sum=0
for i in t:
    sum+=i

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

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

sumt = sum(T)
for d in D:
    print(sumt-(T[d[0]-1]-d[1]))

Submission status: Accepted

Solution code:
# ABC050B - Contest with Drinks Easy
n = int(input())
lst = list(map(int, input().rstrip().split()))
m = int(input())
drinks = [list(map(int, input().rstrip().split())) for _ in range(m)]
total = sum(lst)

for i in drinks:
    print(total - lst[i[0] - 1] + i[1])

Submission status: Accepted

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

res = sum(a)

for i in range(x):
  c, d = (int(_) for _ in input().split())
  print(res + d - a[c-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)]

for P, X in PX:
    print(sum(T) - 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())
    tem = t.copy()
    tem[p-1] = x
    print(sum(tem))

Submission status: Accepted

Solution code:
import sys

n = int(input())
Tn = list(map(int, sys.stdin.readline().rstrip().split()))
m = int(input())
px = [[0,0] for i in range(m)]
for i in range(m):
  px[i] = list(map(int, input().split()))

sm = sum(Tn)
for i in range(m):
  print(sm-Tn[px[i][0]-1]+px[i][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_before = sum(T)
for i in range(M):
    sum_after = sum_before - T[PX[i][0]-1] + PX[i][1]
    print(sum_after)

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 j in range(M):
	tmp = T[P[j] - 1] - X[j]
	print(sum(T) - tmp)

Submission status: Accepted

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

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


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
N = int(input())

Ts = list(map(int,input().split()))
M = int(input())

Ps = []
Xs = []
for i in range(M):
    tmp = Ts.copy()
    p,x = map(int,input().split())
    tmp[p - 1] = x
    print(sum(tmp))

Submission status: Accepted

Solution code:
def read_input():
    n = int(input())
    tlist = list(map(int, input().split()))
    m = int(input())

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

    return n, tlist, drinks


def submit():
    n, tlist, drinks = read_input()

    original_time = sum(tlist)

    for drink in drinks:
        diff = tlist[drink[0] - 1] - drink[1]
        print(original_time - diff)



if __name__ == '__main__':
    submit()

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):
  s = 0
  for j in range(N):
    if j+1 == PX[i][0]:
      s += PX[i][1]
    else:
      s += T[j]
  print(s)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#50
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 = [int(i) for i in input().split()]
M = int(input())
time_sum = sum(T)
for i in range(M):
    P, X = map(int, input().split())
    P -= 1
    print(time_sum - T[P] + X)

Submission status: Accepted

Solution code:
# 入力
N=int(input())
tl=list(map(int,input().split()))
M=int(input())

# 和
sm=sum(tl)

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

  # 変更した場合の変化量を求める
  a=X-tl[P-1]

  # 解答を保存
  al.append(sm+a)

# 出力
for x in al:
  print(x)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

n = int(input())
T=list(map(int,input().split()))
m = int(input())
ans = []

for i in range(m):
    S = copy.copy(T)
    a,b = map(int, input().split())
    S[a-1] = b
    ans.append(sum(S))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

t=[]

line=(input().split())

for i in range(n):
    t.append(int(line[i]))

m=int(input())
sumt=[]

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

for i in range(m):
    print(sumt[i])

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-
n=int(input())
t=list(map(int,input().split()))
m=int(input())

for i in range(m):
    p,m=map(int,input().split())
    x=t[p-1]-m
    print(sum(t)-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:
N = int(input())
T = list(map(int,input().split()))
sumT = sum(T)
M = int(input())
for _ in range(M):
    P, X = map(int, input().split())
    print(sumT + X -T[P-1])

Submission status: Accepted

Solution code:
n = int(input())
t = [int(item) for item in input().split()]
sumt = sum(t)
m = int(input())
px = [[int(item) for item in input().split()] for _ in range(m)]

for p, x in px:
    print(sumt - t[p-1] + x)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
_ = input()
ts = [int(i) for i in input().split(" ")]
m = int(input())
res = []
sumres = sum(ts)
for i in range(m):
    p, x = [int(i) for i in input().split(" ")]
    res.append(sumres - ts[p-1] + x)

for i in res:
    print(i)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    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)
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
lt = int(input())
times = [int(i) for i in input().split(' ')]
ld = int(input())
for drink in range(0, ld):
  i, t = [int(j) for j in input().split(' ')]
  i -= 1
  tmp = times[i]
  times[i] = t
  print(sum(times))
  times[i] = tmp

Submission status: Accepted

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

n=int(input())

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

m=int(input())

for i in range(m):
    a,b=map(int,input().split())
    if t[a-1]==b:
        print(sum(t))
    elif t[a-1]>b:
        print(sum(t)-(t[a-1]-b))
    elif t[a-1]<b:
        print(sum(t)+(b-t[a-1]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N = input()
    T = [ int(ele) for ele in raw_input().split() ]
    M = input()
    P = [0]*M
    X = [0]*M

    for ele in xrange(M):
        P[ele], X[ele] = map(int, raw_input().split())
    
    base_time = sum(T)

    for i in xrange(M):
        after_drank = base_time - T[P[i]-1] + X[i]
        print(after_drank)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

s = 0
for i in T:
    s += i

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())
Tn=list(map(int,input().split()))
M=int(input())
PX=[list(map(int, input().split())) for _ in range(M)]

t = sum(Tn)
for p, x in PX:
    print(t - (Tn[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,k=map(int,input().split())
    tmp=T[p-1]
    T[p-1]=k
    print(sum(T))
    T[p-1]=tmp

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
T = LIST()
M = INT()
PX = [LIST() for _ in range(M)]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
for i in range(M):
    ans = []
    P, X = map(int, input().split())
    for j in range(N):
        if P == j + 1:
            ans.append(X)
        else:
            ans.append(T[j])
    print(sum(ans))

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):
    T1 = T.copy()
    P, X = map(int, input().split())
    T1[P-1] = X
    print(sum(T1))

Submission status: Accepted

Solution code:
n = int(input())
T = [int(t) for t in input().split()]
m = int(input()) # num of drinks
drinks = []

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

for drink in drinks:
    diff = T[drink[0]-1] - drink[1] # 通常の時間 - 加速された時間
    print(sum(T)-diff)

Submission status: Accepted

Solution code:
n = int(input())
T = [int(t) for t in input().split()]
m = int(input()) # num of drinks
drinks = []
diffs = [0 for _ in range(n)] # diff buffs

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

for drink in drinks:
    diff = T[drink[0]-1] - drink[1] # 通常の時間 - 加速された時間
    print(sum(T)-diff)

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

Submission status: Accepted

Solution code:
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
for _ in range(m):
    s = sum(t)
    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 = 0
X = 0
for i in range(M):
	P, X = map(int, input().split())
	print(sum(T) - T[P-1] + X)

Submission status: Accepted

Solution code:
I = lambda:map(int, input().split())
N = int(input())
T = list(I())
M = int(input())
ans = [sum(T)]*M
for i in range(M):
    p, x = I()
    ans[i] = ans[i] - T[p-1] + x
print('\n'.join(map(str, 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, x = map(int, input().split())
    print(sumT + x - T[p-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())
  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 = []
for i in range(m):
  p,x = map(int,input().split())
  px.append([p,x])
for i in range(m):
    time = 0
    for j in range(n):
        if j+1 == px[i][0]:
            time += px[i][1]
        else:
            time += t[j]
    print(time)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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())
ans = []

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

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

Submission status: Accepted

Solution code:
def contest_with_drinks_easy(N: int, T: list, M: int, drinks: list)->list:
    total = sum(T)
    return [total - T[p-1] + m for p, m in drinks]


if __name__ == "__main__":
    N = int(input())
    T = [int(s) for s in input().split()]
    M = int(input())
    drinks = [tuple(int(s) for s in input().split()) for _ in range(M)]
    ans = contest_with_drinks_easy(N, T, M, drinks)
    print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
from functools import reduce
import copy

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    T = list(int(_) for _ in input().split())
    M = int(input().rstrip())
    A = []
    for i in range(M):
        tmp_T = copy.copy(T)
        sum = 0
        p, x = (int(_) for _ in input().split())
        tmp_T[p-1] = x
        for j in tmp_T:
            sum+= j
        A.append(str(sum))
    print('\n'.join(A))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

all_time = sum(t)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())))
summ = sum(t)
for i in range(m):
    idx = lis[i][0] - 1
    val = lis[i][1]
    ans = summ + val - t[idx]
    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, x  = map(int,input().split())
    print(sumt - t[p-1] + x)

Submission status: Accepted

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

for i in range(M):
    x,y = map(int,input().split())
    c = a[x-1]
    a[x-1] = y

    print(sum(a))
    a[x-1] = c

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

res = []

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())
L1 = list(map(int,input().split()))
M = int(input())
for _ in range(M):
    x, y = map(int,input().split())
    print(sum(L1) - L1[x-1] + y)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
print(eval(input()))
"""
#B
n = I()
t = LI()
s = sum(t)
m = I()
for i in range(m):
    p,x = LI()
    p -= 1
    print(s-t[p]+x)
#C
"""
n = I()
a = LI()
d = defaultdict(int)
for i in a:
    d[i] += 1
for i in d.items():
    if i[0] != 0 and i[1] == 1:
        print(0)
        quit()
    elif i[1] > 2:
        print(0)
        quit()
print(pow(2,n//2,mod))
"""

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
t = list(map(int, stdin.readline().split()))
for i in range(int(stdin.readline())):
    p, x = map(int, stdin.readline().split())
    print(sum(t)+x-t[p-1])