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=input()
T=map(int, raw_input().split())
T_sum=sum(T)
M=input()
for i in range(M):
	p,x=map(int, raw_input().split())
	print T_sum-T[p-1]+x

Submission status: Accepted

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

for p,x in D:
  tmp = T[p]
  T[p] = x
  print(sum(T))
  T[p] = tmp

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(M):
    ans = times
    x = drink[i][0] - 1
    y = drink[i][1]
    ans += (y - problems[x])
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

m = int(input())
s = sum(times)

for _ in range(m):
    prob, red = map(int, input().split())
    prob = prob - 1
    t = times[prob]
    print(s - t + red)

Submission status: Accepted

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

    for p, x in PX:
        s = 0
        for i, t in enumerate(T, 1):
            if p == i:
                t = x
            s += t
        print(s)

if __name__ == '__main__':
    main()

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 [0]*m]
for _px in px:
    print(sum(t)-t[_px[0]-1]+_px[1])

Submission status: Accepted

Solution code:
N = int(input())

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

A = T

M = int(input())

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

for i in range(M):
	
	Ans = 0
	
	a = T[PM[i][0] - 1]
	
	T[PM[i][0] - 1] = PM[i][1]
		
	Ans += sum(T)
	
	print(Ans)
	
	T[PM[i][0] - 1] = a

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 17:36:04 2017

"""

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

drinkList = []

for i in range(M):
    PMList = list(map(int, input().split()))
    drinkList.append((PMList[0], PMList[1]))

sumTime = sum(TList)

for d in drinkList:
    print(sumTime - TList[d[0]-1] + d[1])

Submission status: Accepted

Solution code:
num = int(input())
val = [int(x) for x in input().split()]
val_bk = val
kind = int(input())
array = []
for i in range(kind):
    array.append([int(x) for x in input().split()])

for j in array:
    bk = val[j[0]-1]
    val[j[0]-1] = j[1]
    print(sum(val))
    val[j[0] - 1] = bk

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)]
    
    for x in range(M):
        t = 0
        for y in range(N):
            if y + 1 == Px[x][0]:
                t += Px[x][1]
            else:
                t += T[y]
        print(t)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
T = [0] + list(map(int, input().split()))
M = int(input())
ans = []
for i in range(M):
    Pi, Xi, = map(int, input().split())
    tmp = T[:]
    tmp[Pi] = Xi
    ans.append(sum(tmp))
print(*ans, sep="\n")

Submission status: Accepted

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

"""050-b"""

import sys
import pprint
import re

import itertools
pp = pprint.PrettyPrinter(indent=2)

def main():
    """Main function."""
    N = int(input())
    Ts = list(map(int, input().split(' ')))
    M = int(input())
    sum_ = sum(Ts)
    for _ in range(M):
        p, x = list(map(int, input().split(' ')))
        print(sum_ - Ts[p-1] + x)

if __name__ == '__main__':
    sys.exit(main())

Submission status: Accepted

Solution code:
n = int(input())

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

m = int(input())

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

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

Submission status: Accepted

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

all_sum = sum(ts)
for p, x in pxs:
    print(all_sum + (x - ts[p - 1]))

Submission status: Accepted

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


solve()

Submission status: Accepted

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

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

Submission status: Accepted

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



def main():
    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())
        p -= 1 # 0-based
        print(s - T[p] + x)

if __name__ == "__main__": main()

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

x = sum(t)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = tuple(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:
N = int(input())
listT = [int(_) for _ in input().split()]
M = int(input())
total_listT = sum(listT)

answer = []
for i in range(M):
    temp = [int(_) for _ in input().split()]
    answer.append(total_listT - listT[temp[0]-1] + temp[1])

for _ in answer:
    print(_)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
_ = input()
l = map(int,raw_input().strip().split())
n = int(raw_input())
for x in xrange(n):
	a = map(int,raw_input().strip().split())
	temp = l[a[0]-1]
	l[a[0]-1] = a[1]
	print(sum(l))
	l[a[0]-1] = temp

Submission status: Accepted

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

Submission status: Accepted

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

PP=[]
XX=[]

for i in range(M):
    P, X = map(int,input().split())
    PP.append(P)
    XX.append(X)
    
for j in range(0,M):
    TT=T[:]
    PPP=PP[j]
    TT[PPP-1]=XX[j]
    total=sum(TT)
    print(total)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())
T = map(int,raw_input().split(" "))
M = int(raw_input())
P = []
X = []
answer = []
for m in range(M):
	input_line = map(int,raw_input().split(" "))
	P = input_line[0]
	X = input_line[1]
	answer.append(sum(T) + X - T[P-1])

txt = ""
for a in answer:
	print a

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('b1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    t = read_int_list()
    m = read_int()
    p = [0] * m
    x = [0] * m
    for i in range(m):
        p[i], x[i] = read_int_list()
        p[i] -= 1

    s = sum(t)
    for i in range(m):
        j = p[i]
        res = s - t[j] + x[i]
        print(res)


main()

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('b1.in')


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


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    n = read_int()
    t = read_int_list()
    m = read_int()
    p = [0] * m
    x = [0] * m
    for i in range(m):
        p[i], x[i] = read_int_list()
        p[i] -= 1

    for i in range(m):
        res = 0
        for j in range(n):
            if j == p[i]:
                time = x[i]
            else:
                time = t[j]
            res += time
        print(res)


main()

Submission status: Accepted

Solution code:
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())
    tar = ans[p-1]
    ans[p-1] = x
    print(sum(ans))
    ans[p-1] = tar

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    T_list = list(map(int, input().split()))
    M = int(input())
    drink_list = []
    for _ in range(M):
        p, x = map(int, input().split())
        drink_list.append((p, x))

    for p, x in drink_list:
        total = 0
        for i, t in enumerate(T_list, start=1):
            if i == p:
                total += x
            else:
                total += t
        print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N = ri()
T = rli()
sm = sum(T)
M = ri()
for i in range(M):
    p, x = rli()
    print(sm - T[p-1] + x)

Submission status: Accepted

Solution code:
import copy
N = int(input())
t = [int(x) for x in input().split()]
p = []
for _ in range(int(input())):
	p.append([int(x) for x in input().split()])

result = []
ori_t = copy.deepcopy(t)
for i in p:
	t = copy.deepcopy(ori_t)
	t[i[0]-1] = i[1]
	result.append(sum(t))

for i in result:
	print(i)

Submission status: Accepted

Solution code:
num_of_problems = int(input())
times = input().split()
for i in range(num_of_problems):
    times[i] = int(times[i])
num_of_drinks = int(input())
changes = []
for i in range(num_of_drinks):
    l = input().split()
    l[0] = int(l[0])
    l[1] = int(l[1])
    changes.append(l)
for i in changes:
    diff = times[i[0]-1] - i[1]
    times[i[0]-1] = i[1]
    print(sum(times))
    times[i[0]-1] += diff

Submission status: Accepted

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

Submission status: Accepted

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

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

    tmp[P-1] = X
    total.append(sum(tmp))

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

Submission status: Accepted

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


for d in Ds:
    print(sum(Ts) - Ts[d[0] - 1] + d[1])

Submission status: Accepted

Solution code:
import copy

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

Submission status: Accepted

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

import os
import sys

class Main(object):

    def __init__(self):
        pass

    def some_method(self):
        n = int(input())
        ts = list(map(int, input().split()))
        s = sum(ts)
        m = int(input())
        for i in range(m):
            p, x = map(int, input().split())
            print(s + (x - ts[p-1]))
        
        return None

if __name__ == '__main__':
    m = Main()
    m.some_method()

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy

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

t_ = copy.deepcopy(t)
for i in range(0, m):
    t_[px[i][0] - 1] = px[i][1]
    print(sum(t_))
    t_ = copy.deepcopy(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(raw_input())
T = map(int, raw_input().split())
M = int(raw_input())
PX = [map(int, raw_input().split()) for i in xrange(M)]

S = sum(T)
for P, X in PX:
    print S - (T[P - 1] - X)

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

Submission status: Accepted

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

P,X = [],[]

for _ in range(M):
  Pi,Xi = map(int,input().split())
  P.append(Pi-1)
  X.append(Xi)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from copy import deepcopy


def main():
    problems = int(input())
    solve_times = [int(e) for e in input().split()]
    drinks = int(input())

    for i in range(drinks):
        solve_times_copy = deepcopy(solve_times)
        problem_idx, solve_time = [int(e) for e in input().split()]
        problem_idx -= 1
        solve_times_copy[problem_idx] = solve_time
        print(sum(solve_times_copy))


main()

Submission status: Accepted

Solution code:
mondai = int(raw_input())
time_array = raw_input().split(" ")
drink_num = int(raw_input())

for i in range(drink_num):
    d = raw_input().split(" ")
    m_i = int(d[0]) - 1
    d_time = int(d[1])

    s = 0
    for j in range(len(time_array)):
        if j == m_i:
            s += (d_time)
        else:
            s += int(time_array[j])
    print s

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    time = []
    for i in range(m):
        time.append(list(map(int, input().split())))

    for i in range(m):
        result = 0
        for j in range(n):
            if time[i][0]-1 == j:
                result += time[i][1]
            else:
                result += t[j]
        print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 22 16:06:57 2017

@author: 0048005387
"""

N = input()
T = map(int, raw_input().split())

M = input()
PX=[]
for i in range(M):
    PX.append(map(int, raw_input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
problem_num = input()
time_usual = map(int, raw_input().split())
SUM = sum(time_usual)
m = input()
for i in xrange(m):
    p, time_drink = map(int, raw_input().split())
    p -= 1
    print SUM - time_usual[p] + time_drink

Submission status: Accepted

Solution code:
problem_num = int(input())
solve_time = []
sum_time = 0
for t in input().split():
    solve_time.append(int(t))
    sum_time += int(t)

drink_num = int(input())
pair = []
for i in range(drink_num):
    program_num, time = map(int, input().split())
    pair.append((program_num, time))

for i in range(drink_num):
    label = pair[i][0]
    time = pair[i][1]
    print(sum_time + time - solve_time[label - 1])

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

for tmp in range (M):
    ans = P[tmp][1]
    for tmp2 in range (N):
        if tmp2 == P[tmp][0] - 1:
            continue
        else:
            ans += T[tmp2]
    print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in PX:
    temp = T[:]
    temp[i[0]-1] = i[1]
    print(sum(temp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(raw_input().strip())
t = map(int, raw_input().strip().split())

t_all = sum(t)

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

Submission status: Accepted

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

T = 0
for v in t:
    T += v

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !
N = int(input())
data = list(map(int, input().split()))
M = int(input())
drink = [list(map(int, input().split())) for i in range(M)]
S = 0
for i in range(N):
    S += data[i]
for i in range(M):
    print(S - (data[drink[i][0] - 1] - drink[i][1]))

Submission status: Accepted

Solution code:

N = int(input())
T = [int(t) for t in input().split()]
M = int(input())

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

    Tp = T[:]
    Tp[p - 1] = x

    print(sum(Tp))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())
T = [0] + map(int, raw_input().split())
M = int(raw_input())
P = [map(int, raw_input().split()) for _ in range(M)]

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
_ = raw_input()
tests = [int(test) for test in raw_input().split(" ")]
total_time = sum(tests)
drinks = int(raw_input())
for _ in range(drinks):
    i = [int(x) for x in raw_input().split(" ")]
    no, time = i[0], i[1]
    print total_time - (tests[no - 1] - time)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys

def read_data():
    lines = [line.rstrip() for line in sys.stdin]
    ns = [int(n) for n in lines[1].split()]
    ms = [(int(line.split()[0]), int(line.split()[1])) for line in lines[3:]]
    return ns, ms

def main():
    ns, ms = read_data()
    for (drink_num, drink_sec) in ms:
        result = sum(ns) - ns[drink_num-1] + drink_sec
        print result


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#input
T = []
N = int(raw_input())
T = raw_input().split()
M = int(raw_input())
PX = []
X = 0
T1 = []

#input matrix
for i in range(M):
    PX.append(map(int,raw_input().split()))


for j in range(M):
    #new time
    T1 = T[:]
    PJ = PX[j][0]
    XJ = PX[j][1]
    a = int(PJ)
    b = int(XJ)
    T1[a-1] = b
    
    #plus each time
    X = 0
    for k in range(N):
            X += int(T1[k])
    print X

Submission status: Accepted

Solution code:
N = int(input())

Ts = list(map(int,input().split()))
M = int(input())
sumTime = sum(Ts)
for i in range(0,M):
    pi, xi = map(int,input().split())
    print(sumTime + xi - Ts[pi-1])

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


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

main()

Submission status: Accepted

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

summ = sum(T)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
time_sum=sum(a)

k=int(input())
d=[]

for i in range(k):
    p,x=map(int,input().split())
    d.append((p-1,x))

for j in range(k):
    print(time_sum-a[d[j][0]]+d[j][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:
# -*- coding:utf-8 -*-

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

for i in range(M):
    p, x = map(int, input().split())
    count = 0
    for j in range(len(T)):
        if j+1 == p:
            count = count + x
        else:
            count = count + T[j]
    print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
base = sum(T)
result = []
for i in range(M):
    P,X = map(int, input().split())
    result.append(base - T[P-1] + X)
print("\n".join([str(x) for x in result]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    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())
    s = sum(T)
    for i in range(M):
        print(s - T[P[i]-1] + X[i])

if __name__ == '__main__':
    main()