Problem:


Score : 200 points

Problem Statement

Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N.
Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).

Also, there are M kinds of drinks offered to the contestants, numbered 1 through M.
If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.
It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.

Constraints

All input values are integers.

1≦N≦100

1≦T_i≦10^5

1≦M≦100

1≦P_i≦N

1≦X_i≦10^5

Input

The input is given from Standard Input in the following format:

N
T_1 T_2 ... T_N
M
P_1 X_1
P_2 X_2
:
P_M X_M

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

Sample Input 1

3
2 1 4
2
1 1
2 3

Sample Output 1

6
9

If Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.

If Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.

Sample Input 2

5
7 2 3 8 5
3
4 2
1 7
4 13

Sample Output 2

19
25
30



Sample input:
3
2 1 4
2
1 1
2 3


Sample output:
6
9

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
a = int(input())
b = input().split(" ")
c = int(input())
for i in range(c):
  second = 0
  d = input().split(" ")
  e = copy.deepcopy(b)
  e[int(d[0])-1] = d[1]
  for i in range(a):
    second += int(e[i])
  print(second)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
T = [int(x) for x in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
data = []
for _ in range(M):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
sum_T = sum(T)

for i,j in data:
    print(sum_T - T[i-1] + j)

Submission status: Accepted

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

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

Submission status: Accepted

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

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.copy()
    T[p-1] = x
    print(sum(T))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
c = int(input())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# input
n = int(input())
t = list(map(int, input().split()))
s = sum(t)
m = int(input())
for i in range(m):
    o = 0
    p, x = map(int, input().split())
    o = s-t[p-1]+x
    print(o)

Submission status: Accepted

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

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

Submission status: Accepted

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

total = sum(lstT)
lst_Ans = []

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

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

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):
    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:
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

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

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

    # 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())
    # 
    # for i in range(m):
    #     print(sum(t) - t[p[i] - 1] + x[i])


if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    t = list(map(int, 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())

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


if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N, T_li, M, = int(input()), list(map(int, input().split())), int(input())
P_li = [[int (i) for i in input().split()] for j in range(M)]
dummy = 0

for i in range(M):
    dummy = T_li[P_li[i][0] - 1]
    T_li[P_li[i][0] - 1] = P_li[i][1]
    print(sum(T_li))
    T_li[P_li[i][0] - 1] = dummy

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
*T, = map(int, input().split())
total = sum(T)
M = int(input())
drinks = [tuple(map(int, input().split())) for _ in range(M)]
for p_idx, x in drinks:
    print(total - T[p_idx-1] + x)

Submission status: Accepted

Solution code:
import copy
N = int(input())
Ts = list(map(int, input().split()))
wa = sum(Ts)
M = int(input())
d_list = []
for i in range(M):
	p, x = list(map(int, input().split()))
	T = copy.deepcopy(Ts)
	T[p-1] = x
	d_list.append(T)

for i in range(M):
	print(sum(d_list[i]))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

    sum = 0
    for j in t:
        sum += j
    time.append(sum)

for s in time:
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
t_list=[int(s) for s in input().split()]
total=sum(t_list)

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

for p,x in drink:
    print(total - t_list[p-1] + x)

Submission status: Accepted

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

sum = 0
for i in range(N):
    sum += T[i]

D = []
for i in range(M):
    x = list(map(int,input().split()))
    D.append(x)

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

Submission status: Accepted

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
a = []
for i in range(m):
    arr = list(map(int,input().split()))
    a.append(arr)
for i in a:
    t_new = [j for j in t]
    if i[0] <= n:t_new[i[0]-1] = i[1]
    print(sum(t_new))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

eff = list(range(M*2))

for i in range(M):
    eff[i*2], eff[(i*2)+1] = map(int, input().split())
    
for i in range(M):
    total = sum(time) - time[eff[i*2]-1] + eff[(i*2)+1]
    print(total)

Submission status: Accepted

Solution code:
n=int(input())
p=input().rstrip().split(' ')
o=int(input())
for i in range(0,o):
    d=0;
    C=list(p)
    h=input().rstrip().split(' ')
    C[int(h[0])-1] = int(h[1])
    for j in range(0,len(p)):
        d=d+int(C[j])
    print(d)

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
Ts = nl()
M = n()

res = []
for i in range(M):
    P, X = nl()
    TD = Ts[:]
    TD[P-1] = X
    res.append(sum(TD))

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

Submission status: Accepted

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


abc()

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
total = 0
for i in T:
    total += i

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

N = int(input())
lst_T = input().split()
for i in range(len(lst_T)):
    lst_T[i] = int(lst_T[i])
M = int(input())

lst_D = []

for i in range(M):
    lst_D.append(input().split())
    lst_D[i][0] = int(lst_D[i][0])
    lst_D[i][1] = int(lst_D[i][1])

for i in range(M):
    W = lst_T[(lst_D[i][0])-1]
    lst_T[(lst_D[i][0])-1] = lst_D[i][1]
    print(sum(lst_T))
    lst_T[(lst_D[i][0]) - 1] = W

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(M):
    D.append(list(map(int, input().split())))

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = map(int,input().split())
    print(t_sum-T[p-1]+x)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import string
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
T = list(map(int, sys.stdin.readline().split()))
M = int(sys.stdin.readline())
P, X = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

s = sum(T)
for p, x in zip(P, X):
    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):
    t_ = t.copy()
    p, x = map(int, input().split(' '))
    t_[p-1] = x
    print(sum(t_))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n_t = int(input())
t_lis = list(map(int,input().split()))
n_d = int(input())
d_lis = []
for _ in range(n_d):
  d_lis.append(list(map(int,input().split())))
d_dif = [0]*n_d
for i,item in enumerate(d_lis):
  d_dif[i] = item[1] - t_lis[item[0]-1]
sum_t = sum(t_lis)
for num in d_dif:
  print(sum_t + num)

Submission status: Accepted

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

T_sum=sum(T)

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

Submission status: Accepted

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

answer = []
for _ in range(M):
  a,b = map(int,input().split())
  answer.append(s+b-T[a])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B問題
N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = []
for i in range(M):
    px.append(list(map(int, input().split())))
for i in range(M):
    ans = 0
    ans += sum(T) - T[px[i][0]-1] + px[i][1]
    print(ans)

Submission status: Accepted

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

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

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

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

for j in range(m):
    ans=copy.deepcopy(t)
    x=pro[j][0]
    p=pro[j][1]
    ans[x-1]=p
    print(sum(ans))

Submission status: Accepted

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

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


m=int(input())

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

for i in range(m):
    ans=copy.deepcopy(pro)
    ans[drinks[i][0]-1]=drinks[i][1]
    print(sum(ans))

Submission status: Accepted

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

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())
fulltime=sum(t)
for i in range(m):
  print(fulltime-(t[p[i]-1]-x[i]))

Submission status: Accepted

Solution code:
import copy

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

m=int(input())

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

for k in range(m):
    p=drinks[k][0]
    x=drinks[k][1]
    answer=copy.deepcopy(t)
    answer[p-1]=x
    print(sum(answer))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
tn = list(map(int, input().split()))
total = sum(tn)

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

Submission status: Accepted

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

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 _ in range(M)]
for i in range(M):
    p=Drink[i][0]
    x=Drink[i][1]
    answer=copy.deepcopy(T)
    answer[p-1]=x
    print(sum(answer))

Submission status: Accepted

Solution code:
n = int(input())
time = [i for i in map(int,input().split())]
m = int(input())
ch_time = []
for i in range(m):
    ch_time.append([i for i in map(int,input().split()) ])

for i in range(m) :
    num = ch_time[i][0]
    dif = ch_time[i][1] - time[num-1]
    print("{}".format(sum(time)+dif))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

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

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)

sumT = sum(T)

for p,x in zip(P,X):
  print(sumT - (T[p-1]-x))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - Contest with Drinks Easy
https://atcoder.jp/contests/abc050/tasks/abc050_b

"""
import sys


def solve(N, T, M, drinks):
    total = sum(T)
    ans = []
    for p, x in drinks:
        ans.append(total + x - T[p-1])
    return ans


def main(args):
    N = int(input())
    T = [int(t) for t in input().split()]
    M = int(input())
    drinks = [[int(i) for i in input().split()] for _ in range(M)]
    ans = solve(N, T, M, drinks)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

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

Submission status: Accepted

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

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

for (a,b) in zip(p,x):
	nums = 0
	for i in t:
		nums += i
	nums -= t[a-1]-b
	print(nums)

Submission status: Accepted

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

Submission status: Accepted

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

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())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
	p, t = [ int(v) for v in input().split() ]
	print(total_time - time_list[p-1] + t)

Submission status: Accepted

Solution code:
n = int(input())

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

m = int(input())

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

for i in range(m):
    p, x = pxs[i]
    print(total_time - t[p - 1] + x)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


N = int(input())
T = [int(i) for i in input().split()]
M = int(input()) # juice
PM = [[] for i in range(M)]
for i in range(M):
    PM[i] = [int(i) for i in input().split()]

solve_time = sum(T)
for i in range(M):
    p,m = PM[i]
    print(solve_time-T[p-1]+m)

Submission status: Accepted

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

Submission status: Accepted

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

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())
    tot = sum(t)
    tot = tot  -  t[p - 1]+x
    ans.append(tot)
for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    t = f()

    m = f()[0]
    drinks = [f() for i in range(m)]

    tt = sum(t)
    for some in drinks:
        print(tt - (t[some[0]-1] - some[1]))

solve()

Submission status: Accepted

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

for i,j in PM:
    print(sum(T[:i-1]+T[i:])+j)

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

Submission status: Accepted

Solution code:
quiz_number = int(input())
time = list(map(int,input().split()))
drink = int(input())
quiz_time = [list(map(int,input().split())) for i in range(drink)]

for i in range(drink):
    sum = 0
    quiz = quiz_time[i][0]
    change_time = quiz_time[i][1]
    for j in range(quiz_number):
        sum += time[j]
    sum = sum - time[quiz-1] + change_time
    print(sum)

Submission status: Accepted

Solution code:
n = int(input())

t = [int(s) for s in input().split()]
T = t
m = int(input())

for i in range(m):
    

    x,y = list(map(int,input().split()))
    print(sum(t) + y - t[x-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for p,x in [tuple([int(i) for i in input().split()]) for i in range(M)]:
    print(sumT-(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:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for i in range(m)]
sum_t = sum(t)
for i in px:
  key, value = i[0]-1, i[1] 
  ans = sum_t - (t[key]-value)
  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 i in range(m)]

sum_t = sum(t)
for i, j in p:
    print(sum_t - t[i-1] + j)

Submission status: Accepted

Solution code:
n = int(input())
problems = list(map(int,input().split()))
sum_time = sum(problems)
m = int(input())
out = []
for _ in range(m):
    key,time = map(int,input().split())
    out.append(sum_time-problems[key-1]+time)

for time in out:
    print(time)

Submission status: Accepted

Solution code:
from sys import exit, stdin
N = int(stdin.readline().rstrip())
T = [int(_) for _ in stdin.readline().rstrip().split()]
M = int(stdin.readline().rstrip())
PX = [list(map(int, stdin.readline().rstrip().split())) for _ in range(M)]
for i in range(M):
    drink_i = PX[i][0]-1
    print(PX[i][1]+sum(T[:drink_i]+T[drink_i+1:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
input()
t=[0]+list(map(int,input().split()))
for i in range(int(input())):
    ans=copy.deepcopy(t)
    p,x=map(int,input().split())
    ans[p]=x
    print(sum(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
t = [int(i) for i in 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:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = list()
# p = list(range(m))
x = list()
# x = list(range(m))
for i in range(m):
    a, b = map(int, input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    count = 0
    for j in range(n):
        z = p[i] -1
        if (j == z):
            count += x[i]

        else:
            count += t[j]
    print(count)

Submission status: Accepted

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

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())
  ts_i = copy.deepcopy(ts)
  ts_i[p-1] = x
  print(sum(ts_i))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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