Problem:


Score : 200 points

Problem Statement

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

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

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

Constraints

All input values are integers.

1≦N≦100

1≦T_i≦10^5

1≦M≦100

1≦P_i≦N

1≦X_i≦10^5

Input

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

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

Output

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

Sample Input 1

3
2 1 4
2
1 1
2 3

Sample Output 1

6
9

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

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

Sample Input 2

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

Sample Output 2

19
25
30



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


Sample output:
6
9

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
T = list(map(int, sys.stdin.readline().rsplit()))
M = int(input())

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
quest_num = int(input())
times = list(map(int, input().split()))

drink_num = int(input())

for i in range(drink_num):
    q, boost = map(int, input().split())
    print(sum(times) - times[q-1] + boost)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

N = int(input().rstrip())

values = list(map(int, input().rstrip().split()))
keys = list(range(1,N+1))

q_dic = dict(zip(keys, values))
ans = []

M = int(input().rstrip())

drinks = []
for i in range(M):
  a, b = map(int, input().rstrip().split())
  items = {a: b}
  drinks.append(items)

for i in range(len(drinks)):
  key = list(drinks[i].keys())[0]
  val = list(drinks[i].values())[0]
  q_dic[key] = val
  ans.append(sum(q_dic.values()))
  q_dic = dict(zip(keys, values))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = tuple(map(int, input().split()))
M = int(input())
drinks = [list(map(int, input().split())) for _ in range(M)]
for drink in drinks:
    total_time = sum(T) - (T[drink[0]-1] - drink[1])
    print(total_time)

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

def Main(N, T, M, P, X):
    ans = [0]*M
    for i in range(M):
        TT = T.copy()
        TT[P[i]-1] = X[i]
        ans[i] = sum(TT)
    return ans

res = Main(N, T, M, P, X)
for e in res:
    print(e)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ts = list(map(int, input().split()))
    m = int(input())
    pxs = [list(map(int, input().split())) for _ in range(m)]

    for px in pxs:
        ans = 0
        for i in range(n):
            if i+1 == px[0]:
                ans += px[1]
            else:
                ans += ts[i]
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
TT = [int(i) for i in input().split()]
M = int(input())
PP = []
XX = []
for _ in range(M):
    P, X = [int(i) for i in input().split()]
    PP.append(P)
    XX.append(X)

maxTime = 0
sumTime = sum(TT)
for i in range(len(PP)):
    print(sumTime - (TT[PP[i] - 1] - XX[i]))

Submission status: Accepted

Solution code:
n = int(input())
original = list(map(int , input().split()))
m = int(input())
total = sum(original)
for i in range(m):
  copy = original[:]
  a = list(map(int , input().split()))
  copy[a[0] - 1] = a[1]
  print(sum(copy))

Submission status: Accepted

Solution code:
TestNum = int(input())
TimeList = list(map(int,input().split()))
DrinkNum = int(input())
DrinkList = [list(map(int, input().split())) for _ in range(DrinkNum)]
TimeSum = sum(TimeList)
for i in DrinkList:
    print(TimeSum - (TimeList[i[0] -1] - i[1]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

lt = list(map(int, input().split()))
tm1 = sum(lt)

M = int(input())
for i in range(M):
    p, x = map(int, input().split())
    print(tm1 + x - lt[p-1])

Submission status: Accepted

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

def main():
    N = int(input())
    *T, = map(int, input().split())
    S = sum(T)
    M = int(input())

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


main()

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

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

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

Submission status: Accepted

Solution code:
n = int(input())
t_list = list(map(int,input().split()))
m = int(input())
drink_list = [list(map(int,input().split())) 
              for nesya in range(m)]
sum_t_list = sum(t_list)
for drink in drink_list:
  a = drink[0]
  b = drink[1]
  c = t_list[a-1] - b
  print(sum_t_list - c)

Submission status: Accepted

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

d = []
for _ in range(m):
  d.append(tuple(map(int,input().split())))

for i,t_i in d:
  print(sum(t)-t[i-1]+t_i)

Submission status: Accepted

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

d = []
for _ in range(m):
  d.append(tuple(map(int,input().split())))

base = sum(t)
for i,t_i in d:
  print(base-t[i-1]+t_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)]
T = sum(t)
for i in range(m):
    print(T-t[px[i][0]-1]+px[i][1])

Submission status: Accepted

Solution code:
import copy
N=int(input())
T=[int(i) for i in input().split()]
M=int(input())
A=[]
for i in range(M):
    B=T.copy()
    P,M=map(int,input().split())
    B[P-1]=M
    A.append(sum(B))
for t in A:
    print(t)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

total = sum(T)

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

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

Submission status: Accepted

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

sum_ = sum(t_input)

for i in range(m):
    p,x = map(int,px_input[i])
    print(sum_-t_input[p-1]+x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
t_input = list(map(int,input().split()))
m = int(input())
ans_li = []
for i in range(m):
    p,x = map(int,input().split())
    tmp=0
    for i in range(n):
        if p-1==i:
            tmp+=x
        else:
            tmp+=t_input[i]
    ans_li.append(tmp)

for a in ans_li:
    print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
question_num = int(input())
question_resolve_time = list(map(int, input().split()))
drink_num = int(input())

drink_data = []
for i in range(0, drink_num):
    a = list(map(int, input().split()))
    drink_data.append(a)

not_drinking_time = sum(question_resolve_time)

for drink in drink_data:
    result_time = not_drinking_time - question_resolve_time[drink[0] - 1] + drink[1]
    print(result_time)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T=[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])
def sum(A):
    ans=0
    for i in range(len(A)):
        ans+=A[i]
    return ans
sum=sum(T)
for i in range(M):
    a=PX[i][0]
    b=PX[i][1]
    print(sum-T[a-1]+b)

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################

def main():
    N=int(input())
    T=list(map(int,input().split()))
    M=int(input())
    ssum=sum(T)
    for a in range(M):
        p,x=map(int,input().split())
        p-=1
        sssum=ssum-T[p]+x
        print(sssum)
main()

Submission status: Accepted

Solution code:
N = int(input())

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

M = int(input())

def readlines():
    for _ in range(M):
        p, x = map(int, input().split())
        yield p-1, x

px = list(readlines())

total = sum(T)
for p, x in px:
    print(total - T[p] + x)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    tl=list(map(int,input().split()))
    tlsum=sum(tl)
    m=int(input())
    for i in range(m):
        p,x=map(int, input().split())
        print(tlsum-tl[p-1]+x)
resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
    U = T[:]
    U[P - 1] = X
    print(sum(U))

Submission status: Accepted

Solution code:
N=int(input())
listA = list(map(int,input().split()))
R= int(input())
sum_n = sum(listA)
for i in range(R):
    listB = list(map(int,input().split()))
    print(sum_n-(listA[listB[0]-1]-listB[1]))

Submission status: Accepted

Solution code:
N=int(input())
T=list(map(int, input().split()))
M=int(input())
P = []
X = []
for i in range(M):
    a,b = map(int,input().split())
    P.append(a)
    X.append(b)
#print(T,sum(T))
#print(P)
#print(X)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
Ts=LI()
m=I()
for i in range(m):
    a,b=MI()
    ans=sum(Ts)-Ts[a-1]+b
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
T = [int(t) for t in input().split()]
M = int(input())
D = []
for i in range(M):
    D.append([int(p) for p in input().split()])
S = sum(T)
for i in range(M):
    print(S + D[i][1] - T[D[i][0]-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

b_time=sum(t)
for i in range(0,m):
  toi=lis[i][0]
  after_time=lis[i][1]
  before_time=t[toi-1]
  sa=before_time-after_time
  print(b_time-sa)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from copy import deepcopy

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

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

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 = SUM + T[i]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
N = int(input())
lis = [int(x) for x in input().split()]
for j in range(int(input())):
    time = copy.deepcopy(lis)
    p, x = map(int, input().split())
    time[p-1] = x
    print(sum(time))

Submission status: Accepted

Solution code:
n = int(input())
t_l = list(map(int, input().split()))
m = int(input())
x_l = [list(map(int, input().split())) for _ in range(m)] #n行にmつずつ入力される整数
for p, x in x_l:
    cnt = 0
    for i in range(1, n+1):
        if p == i:
            cnt += x
        else:
            cnt += t_l[i-1]
    print(cnt)

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)-T[P[i]-1]+X[i])

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:
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

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

M = int(input())

_all = sum(T)

for _ in range(M):
    p,x = map(int,input().split())
    p-=1

    print(_all - T[p]+x)

Submission status: Accepted

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

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

tmax=sum(t)

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

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int, input().split()))
sec = sum(T)
M = int(input())
px = [list(map(int, input().split())) for _ in range(M)]
for drink in px:
    print(sec - T[drink[0]-1] + drink[1])

Submission status: Accepted

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

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)

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

Submission status: Accepted

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

def main():
    N = int(readline())
    T = list(map(int, readline().rstrip().split()))
    S = sum(T)
    M = int(readline())
    for _ in range(M):
        p, x = map(int, readline().rstrip().split())
        print(S - T[p-1] + x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#2020-04-29
n = int(input()) #問題数
lst = list(map(int,input().split())) #問題にかかる時間
d = int(input()) #ドリンクの数

total_time = sum(lst)
ans = 0
for i in range(d):
    a,b = map(int,input().split()) #a;No/ b;sec
    ans = total_time + b - lst[a - 1]
    print(ans)

Submission status: Accepted

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

p = []
x = []

while True:
  try:
    tp,tx = map(int,input().split())
    p.append(tp)
    x.append(tx)
    
  except:
    break
    
for i in range(m):
  T = copy(t)
  T[p[i]-1] = x[i]
  print(sum(T))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

total = sum(T)

M = int(input())

PX = []
for i in range(M):
  p,x = map(int,input().split())
  PX.append((p,x))
  
for j in PX:
  print(total-T[j[0]-1]+j[1])

Submission status: Accepted

Solution code:
#Beginner 050 B

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

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

lst = []
for i in range(M):
    lst.append(sum(T) - T[PX[i][0]-1] + PX[i][1])

for j in range(M):
    print(lst[j])

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

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