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


def solve(N: int, T: "List[int]", M: int, P: "List[int]", X: "List[int]"):
    ans = []
    ttl = sum(T)
    for i in range(M):
        ans.append(ttl-T[P[i]-1]+X[i])

    for i in ans:
        print(i)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]" 
    X = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        P[i] = int(next(tokens))
        X[i] = int(next(tokens))
    solve(N, T, M, P, X)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import copy
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):
    tmp = copy.deepcopy(T)
    tmp[P[i] - 1] = X[i]
    print(sum(tmp))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
ans = ''
for i in range(M):
    goukei = sum(T)
    P, X = map(int,input().split())
    goukei = goukei + X - T[P-1]
    ans += str(goukei) + "\n"

print(ans[:-1])

Submission status: Accepted

Solution code:
N = int(input())
T = tuple(map(int, input().split()))
M = int(input())
PX = [tuple(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:
from copy import copy
N = int(input())
Tlist = list(map(int,input().split()))
M = int(input())
PXlist = [tuple(map(int,input().split())) for _ in range(M)]

for num,res in PXlist:
    tmp = copy(Tlist)
    tmp[num-1] = res
    print(sum(tmp))

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 i in range(m)]

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

Submission status: Accepted

Solution code:
n = int(input())
*pr, = map(int,input().split())
for i in range(int(input())):
  n, v = map(int, input().split())
  print(sum(pr)-pr[n-1]+v)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
pr = list(map(int,input().split()))
#print(pr)
m = int(input())
f = lambda:map(int,input().split())
for i in range(m):
  n, d = f()
  #print(n,d)
  mot = pr[n-1]
  pr[n-1] = d
  print(sum(pr))
  pr[n-1] = mot

Submission status: Accepted

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

for i in range(M):
    P, X = list(map(int, input().split()))
    print(T_sum - 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):
    T_Copy = copy.copy(T)
    P, X = list(map(int, input().split()))
    T_Copy[P-1] = X
    print(sum(T_Copy))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T=[int(_) for _ in input().split()]
M=int(input())
PX=[[int(i) for i in input().split()] for j in range(M)]
Maxtime=sum(T)
for i in PX:
	print(Maxtime-T[i[0]-1]+i[1])

Submission status: Accepted

Solution code:
# ABC 050 B
N =int(input())
Ts =[int(j) for j in input().split()]
M =int(input())
List=[[int(j) for j in input().split()] for i in range(M)]

for i in range(M):
    Ts_ = Ts.copy()
    Ts_[List[i][0]-1] = List[i][1]
    print(sum(Ts_))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    T = [x for x in map(int, input().split())]
    M = int(input())
    total = sum(T)
    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:
import copy
N = int(input())
Ts=list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,x = map(int,input().split())
    anslist = copy.deepcopy(Ts)
    anslist[p-1]=x
    print(sum(anslist))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

total = sum(T)

ans = []
for i in range(M):
    ans.append(total - T[drinks[i][0]-1] + drinks[i][1])

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    ans = []

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

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    N = int(input())
    t = list(map(int, input().split()))
    M = int(input())

    main()

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())
    l = [j for j in T]
    l[P-1] = X
    ans.append(sum(l))
print('\n'.join(map(str, ans)))

Submission status: Accepted

Solution code:
N = int(input())
times = list(map(int,input().split(' ')))
dtimes = []
M = int(input())
for i in range(M):
  dtimes.append(list(map(int,input().split(' '))))
for drink in dtimes:
  print(sum(times) - times[drink[0]-1] + drink[1])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
  ans = sumT - T[P-1] + X
  print(ans)

Submission status: Accepted

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

Sum = sum(T)

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

Submission status: Accepted

Solution code:
N = int(input())
T = input().split()
T = [int(n) for n in T]
t_length = 0
for o in T:
    t_length += o
P = []
X = []
M = int(input())
for p in range(0, M):
    tmp = input().split()
    P.append(int(tmp[0]))
    X.append(int(tmp[1]))
for q in range(0, M):
    print(t_length - T[P[q]-1] + X[q])

Submission status: Accepted

Solution code:
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(m):
  x=listA[listB[i][0]-1]
  listA[listB[i][0]-1] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]-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)
for i in ans:
    print(i)

Submission status: Accepted

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

ans = []
s = sum(Ts)
for PX in PXs:
    P, X = PX
    ans.append(s - Ts[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())
px = [list(map(int, input().split())) for _ in range(m)]

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

Submission status: Accepted

Solution code:
n,*t=map(int,open(0).read().split())
for p,x in zip(t[n+1::2],t[n+2::2]):print(sum(t[:n])-t[p-1]+x)

Submission status: Accepted

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

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

for i in list:
    print(i)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(M):
    print(sum(Tlist)-Tlist[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())
for i in range(m):
    p,x=[int(j) for j in input().split()]
    time=t[0:p-1]+t[p:]
    print(sum(time)+x)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

n = ip()                                     #入力整数1つ
#n,x= (int(i) for i in input().split())       #入力整数横2つ以上
t = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
m  =  ip()
s = []
for i in range(m):
    a,b= (int(i) for i in input().split())
    c = copy.copy(t)
    c[a-1] = b
    s.append(sum(c))
for i in range(len(s)):
    print(s[i])

Submission status: Accepted

Solution code:
N = int(input())
t = list(map(int, input().split()))
T = [0]
T = T + t

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
tList = [int(x) for x in input().split()]
M = int(input())
px = []
for i in range(M):
    p, x = map(int, input().split())
    px.append((p,x))

base = sum(tList)
for p,x in px:
    print(base - tList[p-1] + x)

Submission status: Accepted

Solution code:
import copy
n = int(input())
times = [int(i) for i in input().split()]
m = int(input())
px = [input().split() for _ in range(m)]
n_times = copy.copy(times)
for p,x in px:
    n_times[int(p)-1] = int(x)
    print(sum(n_times))
    n_times = copy.copy(times)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
T = list(map(int, input().split()))
sum_T = sum(T)
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()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    tmp=t[p-1]
    t[p-1]=x
    print(sum(t))
    t[p-1]=tmp

Submission status: Accepted

Solution code:
N=int(input())
t=list(map(int,input().split()))
T=[0]
T=T+t

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

Submission status: Accepted

Solution code:
"""AtCoder"""

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):
  ans = 0
  for j in range(N):
    if P[i][0] - 1 == j:
      ans += P[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())
l = [list(map(int, input().split())) for i in range(m)]
for j in range(m):
    print(sum(t)-t[l[j][0]-1]+l[j][1])

Submission status: Accepted

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

result = []
for i in range(M):
  cnt = 0
  P, X = map(int,input().split())
  for j in range(N):
    if(P-1 == j):
      cnt += X
    else:
      cnt += T[j]
  result.append(cnt)
for r in result:
  print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=A
m=int(input())
for i in range(m):
  a,b=map(int,input().split())
  print(sum(A)-A[a-1]+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())
    s=0
    for j in range(len(t)):
        if j==p-1:
            s+=x
        else:
            s+=t[j]
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

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):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
T = map(int, raw_input().split())
S = sum(T)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T=[0]+[int(i) for i in input().split()]
M=int(input())
drinks=[[int(i) for i in input().split()] for _ in range(M)]
for drink in drinks:
    copyedT=[i for i in T]
    copyedT[drink[0]]=drink[1]
    print(sum(copyedT))

Submission status: Accepted

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

m=int(input())
p=[[] for _ in range(m)]
for i in range(m):
    pi,xi=map(int,input().split())
    p[i]=[pi,xi]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import copy as c
n=int(input())
a=list(map(int,input().split()))
b=c.deepcopy(a)
m=int(input())
for s in range(m):
  d,f=map(int,input().split())
  a[d-1]=f
  print(sum(a))
  a=c.deepcopy(b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
*a0, = map(int, input().split())
m = int(input())
for _ in range(m):
    k, b = map(int, input().split())
    a = a0[:]
    a[k-1] = b
    print(sum(a))

Submission status: Accepted

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

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 i in range(m)]

for i in range(m):
    T2 = T.copy()
    T2.pop(px[i][0] - 1)
    T2.append(px[i][1])
    print(sum(T2))

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

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

Submission status: Accepted

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

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

sum_T = sum(T)

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

for l in L:
  tmp=T[:]
  tmp[l[0]-1]=l[1]
  print(sum(tmp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def execute(n, tn, m, pxm):
    result = []
    for px in pxm:
        cp = tn[:]
        cp[px[0] - 1] = px[1]
        result.append(sum(cp))
    return result


if __name__ == '__main__':
    n = int(input())
    tn = list(map(int, input().split()))
    m = int(input())
    pxm = []
    for _ in range(m):
        p, x = map(int, input().split())
        pxm.append([p, x])
    result = execute(n, tn, m, pxm)
    print("\n".join(map(str, result)))

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

Submission status: Accepted

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

M  = int(input())
PX = [input() for _ in range(M)]

for px in PX:
    P, X = map(int, px.split())
    print(S - T[P-1] + X)

Submission status: Accepted

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

M  = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
list1 = list(map(int, input().split()))
#print(n, list1)

m = int(input())
for i in range(m):
  p, x = map(int, input().split())
  #print(p,x)
  ans = 0
  for j in range(n):
    ans += x if j == p-1 else list1[j]
  print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = tuple(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 a in ans:
    print(a)

Submission status: Accepted

Solution code:
import copy
n = input()
deftime = list(map(int, input().split()))
r = input()
r = int(r)

for _ in range(r):
  p, x = map(int, input().split())
  temp = copy.deepcopy(deftime)
  temp[p-1] = x
  print(sum(temp))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=int(input())
a=list(map(int,input().split()))
b=int(input())
s=[]
for i in range(b):
    c,d=map(int,input().split())
    s.append(sum(a[:c-1])+sum(a[c:])+d)   
    print(s[i])

Submission status: Accepted

Solution code:
s=int(input())
a=list(map(int,input().split()))
b=int(input())
s=[]
for i in range(b):
    c,d=map(int,input().split())
    s.append(sum(a[:c-1])+sum(a[c:])+d)   
for i in range(b):
    print(s[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t = [int(x) for x in input().split()]
sum_t = sum(t)
sum_list = []

for i in range(int(input())):
    p, x = [int(x) for x in input().split()]
    sum_list.append(sum_t + x - t[p - 1])

for s in sum_list:
    print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 050 B
N = int(input())
T = [int(x) for x in input().split()]
#print(N)#
#print(T)#

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#s = input()
#n, m = map(int, input().split())
#s, t = input().split()
#n, m, l = map(int, input().split())
#s, t, r = input().split()
t = list(map(int, input().split()))
#a = input().split()
#a = [int(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

#t = input()
m = int(input())
#p, q = map(int, input().split())
#p, q = input().split()
#p, q, r = map(int, input().split())
#p, q, r = input().split()
#b = map(int, input().split())
#b = input().split()
#b = [int(input()) for _ in range(m)]
#b = [input() for _ in range(m)]
cnt, ans, mx, mn = 0, 0, 0, 100000000
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())
P,X = [],[]
for i in range(M):
    p,x = map(int,input().split())
    P.append(p)
    X.append(x)

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

Submission status: Accepted

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

Submission status: Accepted

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

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