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

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
t = na()
m = ni()
px = nan(m)

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

Solution (Python):
N = int(input())
t_list = [int(t) for t in input().split()]
M = int(input())
table = [[int(i) for i in input().split()] for m in range(M)]

sum1 = 0
for n in range(N):
    sum1 += t_list[n]

for m in range(M):
    sum2 = sum1 - t_list[table[m][0] - 1] + table[m][1]
    print(sum2)

Solution (Python):

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

m = int(input())

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

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

gokei = sum(T)

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

Solution (Python):
def main():
    N = int(input())
    default_time = list(map(int, input().split()))
    M = int(input())

    drink_list = list()

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

    for d in drink_list:
        P = d[0]
        X = d[1]
        time = default_time[:]
        time[P - 1] = X
        print(sum(time))
main()

Solution (Python):
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))

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

Solution (Python):
n = int(input())
tary = list(map(int,input().split()))
m = int(input())

sumt = sum(tary)


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

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
T = iil()
m = ii()
drink = []
for i in range(m):
    drink.append(iil())

time = sum(T)
for item in drink:
    dif = item[1] - T[item[0]-1]
    print(time + dif)

Solution (Python):
n = int(input())
T_list = list(map(int,input().split()))
summ = sum(T_list)
m = int(input())
drinknum = []
drinktime = []
for x in range(m):
    uketsuke = list(map(int,input().split()))
    drinknum.append(uketsuke[0])
    drinktime.append(uketsuke[1])
for x in range(m):
    print(summ - T_list[drinknum[x]-1] + drinktime[x])

Solution (Python):
import sys

input = sys.stdin.readline


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

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


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

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

for i in range(M):
    pi, xi = map(int, input().split())
    print(whole_time - T[pi-1] + xi)

Solution (Python):
n = int(input())
T = list(map(int, input().split()))
total = sum(T)

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

Solution (Python):
import sys
in1 = sys.stdin.readlines()



N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])

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

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

Solution (Python):
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):
    sum = 0
    for j in range (n):
        if p[i][0] == j+1:
            sum += p[i][1]
        else:
            sum += t[j]
    print(int(sum))

Solution (Python):
def I(): return input()
_=I();t = list(map(int, I().split()))
for _ in range(int(I())):
    s = t[:]
    p, x = map(int, I().split())
    s[p-1] = x
    print(sum(s))

Solution (Python):
N = input()
T_list = list(map(int,input().split()))
M = input()
drink_list = []
for i in range(int(M)):
    drink_dict = {}
    P,X = map(int,input().split())
    drink_dict[P] = X
    drink_list.append(drink_dict)

for d in drink_list:
    for p in d.keys():
        sum_time = 0
        for i in range(1,len(T_list)+1):
            if p == i:
                sum_time += d[p]
            else:
                sum_time += T_list[i-1]
        print(sum_time)

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

total = sum(T)
N = int(input())
ans = []
for i in range(N):
  x,y = map(int, input().split())
  ans.append(total-(T[x-1]-y))
print(*ans, sep='\n')

Solution (Python):
N = int(input())
T = [int(i) for i in input().split(' ')]
M = int(input())
PX = []
for _ in range(M):
    PX.append([int(i) for i in input().split(' ')])
SUM = sum(T)

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

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

for mi in range(m):
  tt = list(x for x in t)
  p, x = map(int, input().split(' '))
  del tt[p-1]

  res = 0
  for value in tt:
    res += value
  print(res + x)

Solution (Python):
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)

Solution (Python):
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])

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

for i in range(0,M):
    s=Ml[i][0]-1
    f=X[s]
    X[s]=Ml[i][1]
    print(sum(X))
    X[s]=f

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

Solution (Python):

n = int(input())
t = [int(s) for s in input().split()]
m = int(input())
p = []
x = []
for _ in range(m):
    tmp = [int(s) for s in input().split()]
    p.append(tmp[0])
    x.append(tmp[1])

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

Solution (Python):


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

Solution (Python):
n=int(input())

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

m=int(input())

goukei = sum(t)

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

Solution (Python):
N = int(input())
times = list(map(int, input().split()))
M = int(input())
probrems = []

for i in range(M):
    probrems.append([int(i) for i in input().split()])
                         
sum_times = []
                    
for p in range(M):
    init_time = times.copy()
    init_time[probrems[p][0]-1] = probrems[p][1]
    sum_times.append(sum(init_time))

for t in sum_times:
    print(t)

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

Solution (Python):

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

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

Solution (Python):
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)

Solution (Python):

import math
import itertools
import statistics

import collections

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

m = int(input())
p = []
d = []

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

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

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

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

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

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

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

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

total = sum(T)

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

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

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    tot = sum(T)

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



main()

Solution (Python):
n = int(input())

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

m = int(input())

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


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

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

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

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

Solution (Python):




"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""





def main():
  _ = int(input())
  L = list(map(int,input().split()))
  m = int(input())
  for _ in range(m):
    idx,cha = map(int,input().split())
    ANS = L.copy()
    ANS[idx-1] = cha
    ans = sum(ANS)
    
    print(ans)
  
if __name__ == '__main__':
  main()

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]

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

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


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


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

    ans = (sum(a))

    m =int(input())

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

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

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

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

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

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

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

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

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

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

goukei = sum(t_L)

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

for i in ans_L:
    print(i)

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

Solution (Python):
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)

Solution (Python):
import sys
input = sys.stdin.readline

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

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

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

Solution (Python):
import sys

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

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

main()

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

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

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

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

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

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

for i in ans:
	print(i)

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

ans=sum(t)

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

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

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

Solution (Python):


import copy


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



for m in range(M):
    drunk_t_list = copy.deepcopy(T_list)
    drunk_t_list[PX_list[m][0] - 1] = PX_list[m][1]
    print(sum(drunk_t_list))

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

ans = sum(T)
for x in X:
    print(ans - T[x[0]-1] + x[1])

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

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

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

Solution (Python):
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for _ in range(m):
  p,x=map(int,input().split())
  if t[p-1]<x:
    print(sum(t)+(x-t[p-1]))
  elif t[p-1]>x:
    print(sum(t)-(t[p-1]-x))
  else:
    print(sum(t))

Solution (Python):
n = int(input())
t = list(map(int, input().split()))
total = sum(t)

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

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

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

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

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

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

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

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

Solution (Python):


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

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


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

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

for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)
for i in range(M):



    dsum = fsum - T[grid[i][0]-1] + grid[i][1]
    print(dsum)

Solution (Python):
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())

N = I()
T = LI()
M = I()
P = [LI() for _ in range(M)]
temp = sum(T)
for x in P:
    print(temp+x[1]-T[x[0]-1])

Solution (Python):

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

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

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

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

sum_t = sum(T)

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

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

t = sum(A)

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

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

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

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

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

total = sum(t)

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

Solution (Python):
n = int(input())
T = list(map(int, input().split()))
m = int(input())
P = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    tmp = T[:]
    tmp[P[i][0] - 1] = P[i][1]
    print(sum(tmp))

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

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