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())
pl = list(map(int, input().split()))
m = int(input())
for i in range(m):
  pl2 = pl.copy()
  a,b = map(int, input().split())
  pl2[a-1]=b
  print(sum(pl2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

# https://atcoder.jp/contests/abc050/tasks/abc050_b

N = int(input())
T_list = list(map(int, input().split()))
M = int(input())

P_list = []
X_list = []
for m in range(M):
    p, x = map(int, input().split())
    P_list.append(p)
    X_list.append(x)

for p in range(M):
    T_d_list = copy.copy(T_list)
    T_d_list[P_list[p] - 1] = X_list[p]

    print(sum(T_d_list))

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = list()
x = list()
for i in range(m):
    a,b = map(int, input().split())
    p.append(a)
    x.append(b)
for i in range(m):
    time = 0
    test = p[i]-1
    for j in range(n):
        if test == j:
            time += x[i]
        else:
            time += t[j]
    print(time)

Submission status: Accepted

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

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:
#abc 050 b
n=int(input())
t=list(map(int,input().split()))
sum_t=sum(t)
m=int(input())
px=[]
for i in range(m):
    p,x=map(int,input().split())
    px.append([p,x])

for i in px:
    henka=t[i[0]-1]-i[1]
    ans=sum_t-henka
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
import copy

N = int(input())
A = [int(i) for i in input().split()]
T = np.array(A)
M = int(input())
P = []
for i in range(M):
  a = [int(i) for i in input().split()]
  P.append(a)
for list in P:
    t = T.copy()
    t[list[0]-1] = list[1]
    print(np.sum(t))

Submission status: Accepted

Solution code:
n = int(input())
T = input().split(' ')
T = [int(x) for x in T]
N = int(input())
S = sum(T)
for i in range(N):
  line = input().split(' ')
  print(S-T[int(line[0])-1]+int(line[1]))

Submission status: Accepted

Solution code:
listP=[]
listX=[]
N=int(input())
T=input().split()
M=int(input())
for a in range(M):
    P,X=input().split()
    listP.append(int(P))
    listX.append(int(X))

for b in range(M):
    listT = [int(b) for b in T]

    listT[listP[b]-1]=listX[b]

    print(sum(listT))

Submission status: Accepted

Solution code:
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    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)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=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())
l = [list(map(int, input().split())) for i in range(m)]
for i in range(m):
    ans = 0
    for j in range(n):
        if j == l[i][0] - 1:
            ans += l[i][1]
        else:
            ans += t[j]
    print(ans)

Submission status: Accepted

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

for i in range(m):
  k = t[(p[i][0])-1]
  t[(p[i][0])-1] = p[i][1]
  print(sum(t))
  t[(p[i][0])-1] = k

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
q = list(map(int, input().split()))
m = int(input())
d = [list(map(int, input().split())) for _ in range(m)]
#print(n,q,m,d)

for i in range(m):
    x = q[:]
    x.pop((d[i][0])-1)
    x.insert((d[i][0]-1),d[i][1])
    print(sum(x))

Submission status: Accepted

Solution code:
def main():
  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 _ in range(m)]
  
  for i in range(m):
    print(sum(t)-t[px[i][0]-1]+px[i][1])
  
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
num=int(input())
times=list(map(int,input().split()))
M=int(input())
t=sum(times)
for a in range(M):
  P,X=map(int,input().split())
  print(t-times[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())
    print(sum(T)-T[p-1]+x)

Submission status: Accepted

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

for _ in range(M):
    a,b=map(int,input().split())
    res=sm+b-T[a-1]
    print(res)

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    t = list(map(int,input().split()))
    m = int(input())
    p = [list(map(int, input().split())) for i in range(m)]
    ans = sum(t)
    for i in range(m):
        print(ans-t[p[i][0]-1]+p[i][1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
PX = [list(map(int,input().split())) for i in range(M)]

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

Submission status: Accepted

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

for x in px:
    sub = x[1] - T[x[0] - 1]
    newSum = sumT + sub
    print(newSum)

Submission status: Accepted

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

n = int(readline())
T = list(map(int,readline().split()))
m = int(readline())
PX = [list(map(int,readline().split())) for i in range(m)]

class Input():
    def __init__(self,n,T,m,PX):
        self.n = n
        self.T = T
        self.m = m
        self.PX = PX

class Calc(Input):
    def __call__(self):
        time_sum = self.requre_sum()
        for i in range(self.m):
            substract = self.add_sub(i)
            print(time_sum - substract)
    
    def requre_sum(self):
        return sum(self.T)
    
    def add_sub(self,i):
        return self.T[self.PX[i][0]-1] - self.PX[i][1]


x = Calc(n,T,m,PX)

x()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T_list = list(map(int, input().split()))
M = int(input())
X_list = []
for i in range(M):
    X = list(map(int, input().split()))
    X_list.append(X)
time_list = []
for i in range(M):
    time = 0
    for j in range(N):
        if X_list[i][0]-1 == j:
            time += X_list[i][1]
        else:
            time += T_list[j]
    time_list.append(time)
for i in range(M):
    print(time_list[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

item_count = int(input().rstrip())
require_time = list(map(int, input().rstrip().split(" ")))
drink_count = int(input().rstrip())

total = sum(require_time)

ans = []
for i in range(drink_count):
    (p,x) = map(int, input().rstrip().split(" "))
    tmp = total - require_time[p-1] + x
    ans.append(tmp)


for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import numpy as np

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

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

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

Submission status: Accepted

Solution code:
def main():
    problem_num = int(input())
    solve_time = list(map(int, input().split()))
    drink_variation = int(input())
    drinks = [tuple(map(int, input().split())) for _ in range(drink_variation)]
    max_solve_time = sum(solve_time)
    for drink in drinks:
        print(max_solve_time - solve_time[drink[0] - 1] + drink[1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

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

M =int(input())

PX = np.ones([M,2])

for i in range(M):
    PX[i][0],PX[i][1] = [int(i) for i in input().split()]
    
ans_pre = sum(T)

ans = np.ones(M)

for i in range(M):
    ans[i] = ans_pre - T[int(PX[i][0])-1] + PX[i][1]
    print(int(ans[i]))

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int, input().split()))
sum_t = sum(t)
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:
import copy

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


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

    for j in range(n):
        ans += s[j]

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC050

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

Submission status: Accepted

Solution code:
import copy

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):
    tt=copy.copy(t)
    tt[dr[i][0]-1]=dr[i][1]
    print(sum(tt))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [list(map(int, input().split()))
    for _ in range(m)]

    main(n, t, m, p_x)

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 = [int(i) for i in input().split()]
M = int(input())
P = []
for i in range(M):
    array = list(map(int, input().strip().split()))
    P.append(array)

for i in range(M):
    a = int(P[i][0])
    b = T[a-1] - P[i][1]
    print(sum(T) - b)

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

    ans.append(a)

for a in ans:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

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

tmp = sum(T)

for i in range(M):
  print(tmp - (T[pm[i][0] - 1] - pm[i][1]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import  copy
n=int(input())

*t,=map(int,input().split())
t=[0]+t
m=int(input())
for _ in range(m):
	p,x=map(int,input().split())
	nt=copy(t)
	nt[p]=x
	print(sum(nt))

Submission status: Accepted

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

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=sum(t)-t[p-1]+x
    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)]
T=sum(t)
for _ in range(m):
  print(T-t[px[_][0]-1]+px[_][1])

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])

sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    tot = sumT - time[PP-1] + x[i]
    print(tot)

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.append(list(map(int, input().split())))

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

Submission status: Accepted

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

# input
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for _ in range(m):
    a, b = map(int, input().split())
    p.append(a)
    x.append(b)

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

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:
f = lambda:map(int,input().split())
n = int(input())
l = list(f())
for _ in range(int(input())):
  p,x = f()
  print(sum(l)-l[p-1]+x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
M種類のうちの1個飲める
"""
#solution:
#潜 影 蛇 手 ! !
N=int(input())
T=list(pin())#問題iを解くのに本来必要な時間
M=int(input())
Drinks=([tuple(pin()) for _ in range(M)])
p=[0]*N
for i in range (M):
    j=sum(T)
    print(j-T[Drinks[i][0]-1]+Drinks[i][1])

#print(["No","Yes"][(b[3]-b[0]-b[2]-(b[1]%2)+1>=0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
a=[[int(i) for i in input().split()] for l in range(m)]
for y in a:
    w=[]
    for x in range(len(t)):
        if y[0]-1==x:w.append(y[1])
        else:w.append(t[x])
    print(sum(w))

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)

ans=[]
m=sum(T)
for i in range(M):
    m=sum(T)
    m=m-T[P[i]-1]
    m=m+X[i]
    ans.append(m)

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())
a=0
for i in range(m):
    p,x=map(int,input().split()) #pは問題番号,xは時間
    a=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=a

Submission status: Accepted

Solution code:
n = int(input())
tl = list(map(int, input().split()))
m = int(input())
pl = list(list(map(int, input().split())) for _ in range(m))

t_sum = sum(tl)
for p in pl:
    print(t_sum - (tl[p[0] - 1] - p[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)]
s=sum(T)

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

Submission status: Accepted

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

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

for a in ans:
    print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1

Submission status: Accepted

Solution code:
x=int(input())
first=list(map(int,input().split()))
drink_count=int(input())
count=0
Total=sum(first)
drink=[list(map(int,input().split())) for i in range(drink_count)]
for T in range(drink_count):
    change_num = drink[count][0]
    score = first[change_num-1]-drink[count][1]
    print(Total-score)
    count+=1

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

Submission status: Accepted

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

s = sum(t)

for i in range(m):
    p, x = px[i][0], px[i][1]
    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())
    ans.append(sum(T) - T[P-1] + X)
print(*ans, sep="\n")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T_N=input().split()
list_time = []
for i in range(N):
    list_time.append(int(T_N[i]))
#Ti秒の総和を求める
sum=sum(list_time)
M=int(input())
for i in range(M):
    p,x=map(int,input().split())
#ドリンク飲んだ時と飲まないときの差を元の合計に足す。
    ans=sum+x-list_time[p-1]
    print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t_N = input().split()
list_Time = []
for id in range(n):
    list_Time.append(int(t_N[id]))
sum = sum(list_Time)
m = int(input())
for id in range(m):
    p, x = map(int, input().split())
    answer = sum + x - list_Time[p - 1]
    print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import copy

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
Total = sum(T)
M = int(input())
drinks = []
for _ in range(M):
  p,x = map(int,input().split())
  drinks.append([p,x])
for drink in drinks:
  Ans = Total -T[drink[0]-1] + drink[1]
  print(Ans)

Submission status: Accepted

Solution code:
n = int(input())
t_N = input().split()
list_Time = []
for id in range(n):
    list_Time.append(int(t_N[id]))
sum = sum(list_Time)
m = int(input())
for id in range(m):
    p, x = map(int, input().split())
    answer = sum + x - list_Time[p - 1]
    print(answer)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
li = [0] * M
for i in range(M) :
    li[i] = [int(i) for i in input().split()]
ans = [0] * M
sum = 0
for i in range(N) :
    sum += T[i]
for i in range(M) :
    k = sum - T[li[i][0] - 1] + li[i][1]
    ans[i] = k
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())
P = [list(map(int, input().split())) for i in range(M)]

sum = 0

for i in range(len(P)):
    t = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    for j in T:
        sum += j
    print(sum)
    sum = 0
    T[P[i][0] - 1] = t

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:
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 9 + 7

N = int(readline())
T = list(map(int, readline().split()))
M = int(readline())

num = sum(T)
for _ in range(M):
    P, X = map(int, readline().split())
    print(num + 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())
    ans = sum(T) - T[P - 1] + X
    print(ans)

Submission status: Accepted

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
T=many_int()

M=one_int()

for i in range(M):
    P,X=two_int()
    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()))

ans = sum(t)
m = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
px = []
for i in range(m):
    px.append([int(i) for i in input().split()])

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

Submission status: Accepted

Solution code:
def solve(n, T, m, PX):
    return [sum(x if i + 1 == p else t for i, t in enumerate(T)) for (p, x) in PX]

_n = int(input())
_T = list(map(int, input().split()))
_m = int(input())
_PX = [map(int, input().split()) for _ in range(_m)]
print(*solve(_n, _T, _m, _PX), sep='\n')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
times = list(map(int,input().split()))
m = int(input())
drinks =[]

for i in range(m):
    drinks.append(list(map(int,input().split())))

total_time = sum(times) 

for i in range(m):
    time = times[drinks[i][0]-1]
    result = total_time - time + drinks[i][1]
    print(result)

Submission status: Accepted

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

for p, x in px:
    total = 0

    for i in range(N):
        if i + 1 == p:
            total += x
        else:
            total += T[i]

    print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input(), 10)
times = list(map(int, input().split()))

M = int(input(), 10)
answers = []
for _ in range(M):
    problem, become_time = tuple(map(int, input().split()))
    answer_elem = times[:]
    answer_elem[problem-1] = become_time
    answers.append(answer_elem)

for ans in answers:
    print(sum(ans))

Submission status: Accepted

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

for i in range(m):
    arr = list()
    for j in range(n):
        if p[i] == j+1:
            arr.append(x[i])
        else:
            arr.append(t[j])
    print(sum(arr))

Submission status: Accepted

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

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

Submission status: Accepted

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

#print(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())
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:
Plist =[]
Xlist =[]
boxlist =[]
ans = 0

N = int(input())
T = input().split()
M = int(input())

for j in range(M):
    P, X = map(int, input().split())
    Plist.append(P)
    Xlist.append(X)
    
for k in range(M):
    for l in range(len(T)):
        a = int(T[l])
        boxlist.append(a)
    
    num = Plist[k] -1
    
    boxlist[num] = Xlist[k]
    
    for j in range(len(boxlist)):
        ans = ans + boxlist[j]

    print(ans)
    ans = 0
    boxlist.clear()