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:

import math
import itertools
import statistics
#import numpy as np
import collections

n = int(input())
t = list(map(int, input().split()))
#a = list(map(int, input().split()))
m = int(input())
p = []
d = []

for i in range(m):
    x,y = [int(j) for j in input().split()]
    p.append(x)
    d.append(y)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

total = sum(T)

for drink in PX:
    print(total - T[drink[0]-1] + drink[1])

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

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    tot = sum(T)

    for i in range(M):
        diff = T[PX[i][0]-1] - PX[i][1]
        print(tot - diff)



main()

Submission status: Accepted

Solution code:
n = int(input())

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

m = int(input())

px = [[] for i in range(m)]
for i in range(m):
    px[i] += 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:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
X = [[] for _ in range(M)]
for i in range(M):
    X[i] = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
x = []
y = []
for i in range(M):
    x1,y1 = list(map(int,input().split()))
    x.append(x1)
    y.append(y1)
S = sum(T)
def gori(i):
    v = S - int(T[x[i]-1]) + int(y[i])
    return v
for ans in map(gori, range(M)):
    print(ans)
# print(N)
# print(T)
# print(M)
# print(x)
# print(y)
# print(S)

Submission status: Accepted

Solution code:
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  _ = int(input())
  L = list(map(int,input().split()))
  m = int(input())
  for _ in range(m):
    idx,cha = map(int,input().split())
    ANS = L.copy()
    ANS[idx-1] = cha
    ans = sum(ANS)
    
    print(ans)
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

for i, j in PX:
    print(sum(A) - A[i-1] + j)

Submission status: Accepted

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    n =int(input())
    a = [int(i) for i in input().split()]

    ans = (sum(a))

    m =int(input())

    for i in range(m):
        b, c = map(int, input().split())
        print(ans -a[b-1] +c )

Submission status: Accepted

Solution code:
n = int(input())
T = [int(x) for x in input().split()]
m = int(input())
drink = [[int(x) for x in input().split()] for i in range(m)]
time = sum(T)
for d in drink:
  print(time - T[d[0]-1] + d[1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(sum(alist))

Submission status: Accepted

Solution code:
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    empty = []
    for i in range(0,M):
        empty.append(time_sum() - Tlist[PXlist[i][0]-1] + PXlist[i][1])
    return empty
for i in time_cal():
    print(i)

Submission status: Accepted

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

p_L,x_L = [],[]
max_num = 0

goukei = sum(t_L)

ans_L = []
for _ in range(m):
    p,x = map(int,input().split())
    #p_L.append(p)
    #x_L.append(x)
    tmp = t_L[p-1] - x
    ans = goukei-tmp
    ans_L.append(ans)
    #max_num = max(x - t_L[p-1])

for i in ans_L:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
t=list(map(int,input().split()))
sumt=sum(t)
m=int(input())
px = [list(map(int, input().split())) for _ in range(m)]
for i in range(m):   
    a=t[px[i][0]-1]
    b=px[i][1]
    print(sumt-a+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:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

for i in range(m):
  data= input().rstrip().split()
  print(sum(t)-t[int(data[0])-1]+int(data[1]))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    tt=LI()
    s=sum(tt)
    m=II()
    for _ in range(m):
        p,x=MI()
        print(s-tt[p-1]+x)

main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sumArray(n):
    sum = 0
    for i in range(len(n)):
        sum += n[i]
    return sum

n = int(input())
t = list(map(int, input().rstrip().split()))
m = int(input())
sum = sumArray(t)
temp = sum
for i in range(m):
    data = list(map(int, input().split()))
    sum = sum - t[data[0] - 1] + data[1]
    print(sum)
    sum = temp

Submission status: Accepted

Solution code:
n = int(input())
t_list = list(map(int, input().split()))
m = int(input())
p_list = []
while True:
	try:
		p_list.append(list(map(int,input().split())))
	except:
		break
for p in p_list:
	p_index = p[0] - 1
	p_point = p[1]
	total = 0
	for num in range(0, n):		
		if num == p_index:
			total = total + p_point
		else:
			total = total + t_list[num]
	print(total)

Submission status: Accepted

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

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

ans=sum(t)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import copy

# 標準入力の取得
N = int(input())
T_list = list(map(int, input().split()))
M = int(input())
PX_list = [list(map(int, input().split())) for i in range(M)]

# 求解
# 各ドリンク毎に、リストを作成し、その総和を出力する
for m in range(M):
    drunk_t_list = copy.deepcopy(T_list)
    drunk_t_list[PX_list[m][0] - 1] = PX_list[m][1]
    print(sum(drunk_t_list))

Submission status: Accepted

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

ans = sum(T)
for x in X:
    print(ans - T[x[0]-1] + x[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())
for i in range(M):
  b = T.copy()
  p,x = map(int,input().split())
  b[p-1] = x
  print(sum(b))

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
S = sum(T)
M = int(input())
for k 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 _ in range(m):
  p,x=map(int,input().split())
  if t[p-1]<x:
    print(sum(t)+(x-t[p-1]))
  elif t[p-1]>x:
    print(sum(t)-(t[p-1]-x))
  else:
    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())
    diff = x - t[p-1]
    print(total + diff)

Submission status: Accepted

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

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

for j in range(M):
  #print(j,P[j],X[j],T[P[j]-1])
  if P[j] <=N:
    diff = T[P[j]-1] - X[j]
  else:
    diff=0
  print(T_sum - diff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = [int(x) for x in input().split()]
t_all = sum(t)
m = int(input())
for _ in range(m):
    p, x = [int(x) for x in input().split()]
    print(t_all - (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 p,x in PX:
  t = T[p-1]
  T[p-1] = x
  print(sum(T))
  T[p-1] = t

Submission status: Accepted

Solution code:
# coding: utf-8

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

Submission status: Accepted

Solution code:
def main():
    import sys
    n = int(input())
    t = tuple(map(int, input().split()))
    total = sum(t)
    m = int(input())
    for i in sys.stdin:
        p,x = map(int, i.split())
        print(total - t[p - 1] + x)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

for m in range(M):
  p, t = map(int, input().split())
  #print(Ts[p-1])
  #print(t)
  #print((Ts[p-1]-t))
  print(base_ - (Ts[p-1]-t))

Submission status: Accepted

Solution code:
import copy
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
p_list = [[int(j) for j in input().split()] for i in range(m)]

for p in p_list:
    tmp = copy.deepcopy(t)
    tmp[p[0]-1] = p[1]
    print(sum(tmp))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC050.B
N =int(input())
T = list(map(int,input().split()))
S = sum(T)
M = int(input())

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

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

for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)
for i in range(M):
##    print("gridi0="+str(grid[i][0]))
##    print("grioi1="+str(grid[i][1]))
##    print("T="+str(T[grid[i][0]-1]))
    dsum = fsum - T[grid[i][0]-1] + grid[i][1]
    print(dsum)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
T = LI()
M = I()
P = [LI() for _ in range(M)]
temp = sum(T)
for x in P:
    print(temp+x[1]-T[x[0]-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

sum_t = sum(T)

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

Submission status: Accepted

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

t = sum(A)

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

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

T_sum=sum(T)
drink_result=0
for i in range(M):
    print(T_sum-T[P[i][0]-1]+P[i][1])

Submission status: Accepted

Solution code:
n=int(input())
c=list(map(int,input().split()))
d=c.copy()
g=int(input())
for _ in range(g):
	a,b=map(int,input().split())
	d[a-1]=b
	print(sum(d))
	d=c.copy()

Submission status: Accepted

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

total = sum(t)

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

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

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

wa = sum(T)
for i in range(M):
    ans = wa -T[l[i][0] - 1] + l[i][1]
    print(ans)

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    t = list(map(int, input().strip().split()))
    
    m = int(input().strip())

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


if __name__ == '__main__':
    main()

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=list(map(int,input().split()))
    P.append(p)
    X.append(x)
for m in range(M):
    s=0
    for n in range(N):
        if n+1==P[m]:
            s+=X[m]
        else:
            s+=T[n]
       #print(n+1,s)
    print(s)

Submission status: Accepted

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

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

def main():
    mod=10**9+7
    N=I()
    T=LI()
    M=I()
    P=[0]*M
    X=[0]*M
    for i in range(M):
        P[i],X[i]=MI()
    S=sum(T)
    for i in range(M):
        print(S-T[P[i]-1]+X[i])
    

main()

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:
import numpy as np
N = int(input())
T_k = list(map(int,input().split()))
M = int(input())

Total_time_ord = sum(T_k)           
subtraction = 0
drink_time = Total_time_ord
d_list = np.array([])

for i in range(M):
    
    PX = list(map(int,input().split()))
    P = PX[0]
    X = PX[1]
    drink_cos = drink_time + X - T_k[P-1]
    d_list = np.append(d_list,drink_cos)
    drink_cos = Total_time_ord

for i in range(M):
    print("{}".format(int(d_list[i])))

Submission status: Accepted

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

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:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    T=list(map(int,input().split()))
    M=int(input())
    P, X = [0] * M, [0] * M
    for i in range(M):
        P[i], X[i] = map(int, input().split())

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

resolve()

Submission status: Accepted

Solution code:
import copy
n=int(input())
t=[int(i) for i in input().split()]
m=int(input())
for j in range(m):
  s=copy.copy(t)
  x,pn=map(int,input().split())
  s[x-1]=pn
  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):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

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

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []; x = []
s = sum(t)

for i in range(m):
    S,T = input().split()
    p.append(int(S))
    x.append(int(T))

for j in range(m):
    ans = s - (t[p[j]-1] - x[j])
    print(ans)

Submission status: Accepted

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

for _ in range(M):
  P, X = list(map(int, input().split()))
  sum = 0
  for i in range(len(Ts)):
    if i + 1 == P:
      sum += X
    else:
      sum += Ts[i]
  
  print(sum)

Submission status: Accepted

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

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())
for i in range (M):
	ans=0
	P,X=map(int,input().split())
	for j in range (N):
		if j==P-1:
			ans+=X
		else:
			ans+=T[j]
	print(ans)

Submission status: Accepted

Solution code:
N = int(input())

TList = input().split()

M = int(input())

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


for i in List:
    sum = 0
    for j in range(N):
        if int(i[0]) == int(j+1):
            sum = sum + int(i[1])
        else :
            sum = sum + int(TList[j])
    print(sum)

Submission status: Accepted

Solution code:
input1 = raw_input()

input2 = []
for str in raw_input().split():
    input2.append(int(str))

input3 = raw_input()

input4 = []
for num in range(int(input3)):
    input4.append(raw_input())

for value in input4:
    result = 0
    list1 = list(input2)
    value = value.split()
    list1[int(value[0]) - 1] = int(value[1])
    for num in list1:
        result = result + num
    print result

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    # 入力
    #   N
    n = int(input())
    #   T_N
    t = [int(e) for e in input().split(' ')]
    # M
    m = int(input())
    # P_M, X_M
    p = []
    x = []
    for i in range(m):
        p_i, x_i = [int(e) for e in input().split(' ')]
        p.append(p_i)
        x.append(x_i)
    
    #print(f'【入力】n: {n}, t: {t}, m: {m}, p: {p}, x: {x}')
    
    # ドリンクごとに出力
    for drink_i in range(m):
        ans = 0
        # 問題ごとに時間を加算
        for p_i in range(n):
            #print(f'問題:{p_i} p[{drink_i}]: {p[drink_i]}')
            if p[drink_i] == p_i+1:
                # ドリンク飲む
                #print(f'x[{drink_i}]: {x[drink_i]}')
                ans += x[drink_i]
            else:
                # ドリンク飲まない
                #print(f't[{drink_i}]: {t[drink_i]}')
                ans += t[p_i]
        # 合計時間を出力
        print(ans)

Submission status: Accepted

Solution code:
N=int(input())
T=[int(x)for x in input().split()]
M=int(input())
p=[0]*M
x=[0]*M
for i in range(M):
    p[i],x[i]=map(int,input().split())
k=0
for j in range(N):
    k+=T[j]
for i in range(M):
    ans=k+x[i]-T[p[i]-1]
    print(ans)

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

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

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:
#!/usr/bin/env python3

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

total = sum(s)

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

Submission status: Accepted

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

    S = sum(T)

    for p in P:
        d = T[p[0] - 1] - p[1]
        print(S - d)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

M = int(input())

P = np.ones(M)
X = np.ones(M)

for i in range(M):
    
    P[i],X[i] = [int(i) for i in input().split()]
    
ans = sum(T)

for i in range(M):
    ans_ = int(ans + X[i] - T[int(P[i])-1])
    print(ans_)

Submission status: Accepted

Solution code:
N = int(input())
time = tuple(map(int,input().split()))
M = int(input())
time_2 = list(time)

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