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:
# -*- coding: utf-8 -*-
# problem B

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

Submission status: Accepted

Solution code:
#ABC050B

n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
v=[]
for i in xrange(m):
 u=t[:]
 p,x=map(int,raw_input().split())
 u[p-1]=x
 v.append(sum(u))
for i in xrange(m):
 print v[i]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#002
N = int(input())
T = [int(i) for i in input().split(" ")]
M = int(input())
P=[i for i in range(M)]
X=[i for i in range(M)]
for i in range(M):
    P[i],X[i]= [int(j) for j in input().split(" ")]
for i in range(M):
    temp = T[P[i]-1]
    T[P[i]-1]=X[i]
    print(sum(T))
    T[P[i]-1] = temp

Submission status: Accepted

Solution code:
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
pt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=list(t)
    tmp[pt[i][0]-1]=pt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for i in xrange(m):
    print(ans[i])

Submission status: Accepted

Solution code:
import copy
n=int(raw_input())
t=map(int,raw_input().split())
m=int(raw_input())
pt=[map(int,raw_input().split()) for _ in xrange(m)]
ans=[0]*m
for i in xrange(m):
    tmp=copy.deepcopy(t)
    tmp[pt[i][0]-1]=pt[i][1]
    for j in xrange(n):
        ans[i]+=tmp[j]
for i in xrange(m):
    print(ans[i])

Submission status: Accepted

Solution code:
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())
    print(total-t[p-1]+x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())
line = map(int,raw_input().split(' '))
M = int(raw_input())
for i in range(M):
    x = map(int,raw_input().split(' '))
    s = sum(line)-(line[x[0]-1]-x[1])
    print s

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
a = [0] + map(int,stdin.readline().split())
m = int(stdin.readline())
s = sum(a)
for _ in xrange(m):
 x,y = map(int,stdin.readline().split())
 print s  + y - a[x]

Submission status: Accepted

Solution code:
n = input()
t = map(int,raw_input().split())
m = input()
tot = reduce(lambda x,y: x+y,t)
for d in xrange(m):
    temp = tot
    p,x = map(int,raw_input().split())
    temp -= t[p-1]
    temp += x
    print temp

Submission status: Accepted

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

M = int(input())
X = []
for _ in range(M):
    x_list = list(map(int, input().split(" ")))
    X.append(x_list)

T_sum = sum(T)
for (i, x) in X:
    i -= 1
    diff = T[i] - x
    print(T_sum - diff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力受け取り
N = int(input())
time_list = input().split()
# strからintに型変換
time_list = [int(i) for i in time_list]
M = int(input())

i = 0
while i < M:
    time_i = time_list
    P_i, X = map(int, input().split())
    P_i_original = time_list[P_i - 1]
    time_i[P_i - 1] = X
    result = sum(time_i)
    time_list[P_i - 1] = P_i_original
    print(result)
    i +=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

n=int(input())
temps=list(map(int,stdin.readline().split()))
total=sum(temps)
m=int(input())

for i in range(m):
    prob,tBoisson=map(int,stdin.readline().split())
    actu=total-temps[prob-1]+tBoisson
    print(actu)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n = input()
ti = input().split()
sum_ti = sum(map(int, ti))

m = input()
for m in range(int(m)):
    px = input().split()
    sum_p = sum_ti - int(ti[int(px[0])-1]) + int(px[1])
    print(sum_p)

Submission status: Accepted

Solution code:
n = int(input())
li = [0] * n
li = list(map(int, input().split()))
result = sum(li)

m = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
li = [0] * n
li = list(map(int, input().split()))
result = sum(li)

m = int(input())
r1 = [0] * m
r2 = [0] * m

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

Submission status: Accepted

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

for i in range(M):
      org = T_res[PX[i][0]-1]
      T_res[PX[i][0]-1] = PX[i][1]
      print(sum(T_res))
      T_res[PX[i][0]-1] = org

Submission status: Accepted

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

i = 0
while i < m:
    p = list(map(int, input().split()))
    tn = t[:]
    tn[p[0] - 1] = p[1]
    total = sum(tn)
    print(str(total))
    i += 1

Submission status: Accepted

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

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

sum = sum(T)

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

Submission status: Accepted

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

for _ in range(m):
	p,x = map(int,input().split())
	origin.append(t[p-1])
	t[p-1] = x
	ans.append(sum(t))
	t[p-1] = origin[0]
	origin = []

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

Submission status: Accepted

Solution code:
n=int(input())
t=[int(i) for i in input().split()]
max=sum(t)
m=int(input())
sum_list=[]
for i in range(m):
    index,value=[int(j) for j in input().split()]
    index-=1
    temp=t[index]
    t[index]=value
    sum_list.append(sum(t))
    t[index]=temp
for i in sum_list:
    print(i)

Submission status: Accepted

Solution code:
n = input()
ti = map(int, raw_input().split())

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

for i in range(len(xi)):
	p = xi[i][0]
	x = xi[i][1]
	s = 0
	for j in range(n):
		if(j == p-1):
			s += x
		else:
			s += ti[j]
	print s

Submission status: Accepted

Solution code:
N=int(raw_input())
T=map(int, raw_input().split())
M=int(raw_input())
for i in xrange(M):
    p, x = map(int, raw_input().split())
    ans = 0
    for j in xrange(N):
        if j+1 == p:
            ans += x
        else:
            ans += T[j]
    print ans

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp_list = t_list

for i in range(m):
    line = input().rstrip().split()
    line = [int(x) for x in line]
    before = tmp_list[line[0]-1]
    val = line[1]

    tmp_list[line[0]-1] = val

    print(sum(tmp_list))

    tmp_list[line[0]-1] = before

Submission status: Accepted

Solution code:
n = int(input())
t_lst = [int(x) for x in input().split()]
m = int(input())
px_lst = [tuple(int(x) for x in input().split()) for _ in range(m)]

total_time = sum(t_lst)

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

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    n = sys.stdin.readline().rstrip()

    while n:
        t = [int(i) for i in raw_input().split()]
        m = int(raw_input())
        total = sum(t)
        for i in xrange(1, m + 1):
            p, x = [int(j) for j in raw_input().split()]
            print total - t[p - 1] + x

        n = sys.stdin.readline().rstrip()

if __name__ == "__main__":
    main(sys.argv)

Submission status: Accepted

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

m = int(raw_input())
ans = 0
for i in xrange(0, m):
    p,x = map(int,raw_input().split())
    temp = T[p-1]
    T[p-1] = x
    print sum(T)
    T[p-1] = temp

Submission status: Accepted

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

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

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())
sT = input().split()
T = []
P = []
X = []
for i in range(N):
    T.append(int(sT[i]))
M = int(input())
for i in range(M):
    PX = input().split()
    P.append(int(PX[0]))
    X.append(int(PX[1]))


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for drink in drinks:
    total = 0
    for i in range(n):
        if i+1 != drink[0]:
            total += t[i]
        else:
            total += drink[1]
    print(total)

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

Submission status: Accepted

Solution code:
N=int(raw_input().split()[0])
T=map(int,raw_input().split())
M=int(raw_input().split()[0])
S=sum(T)

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

Submission status: Accepted

Solution code:
#coding:utf-8
import math
import string
import time
import fractions



n = int(raw_input())
t = map(int, raw_input().split())
m = int(raw_input())
p = []
for i in range(m):
	p.append(map(int, raw_input().split()))

ret = 0
su = sum(t)
for i in p:
	print su - (t[i[0] - 1] - i[1])

Submission status: Accepted

Solution code:
n = input()
t = map(int, raw_input().split())
s = sum(t)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

P, X = list(), list()

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

ans = sum(T)

for m in range(M):
    arg = P[m] - 1
    val = X[m]

    print(ans - T[arg] + val)

Submission status: Accepted

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

s = sum(t)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#Contest with Drinks Easy
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    a,b=map(int,input().split())
    total=t
    total[a]=b
    print(sum(total))

Submission status: Runtime Error

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())
    total=t
    total2[a]=b
    print(sum(total2))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sum_l=sum(l)

for i in range(m):
  p,x=map(int,input().split())
  ams=sum_l-l[p-1]+x
  print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
l=[0]+list(map(int,input().split()))\
ans=sum(l)
for i in range(int(input())):
  a,s=map(int,input().split())
  print(ans-l[a]+s)

Submission status: Runtime Error

Solution code:
N = int(input())
P=[]
T=input()
M = int(input())
for i in range(M):
  P.append(tuple(map(int,input().split())))
Tlist = []
for i in range(N):
  Tlist.append(int(T[2*i]))
for i in range(M):
  A = 0
  for j in range(N):
    if Tlist[j] == P[i][0]-1:
      A += P[i][1]
    else:
      A += Tlist[j]
  print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <array>

using namespace std;

int main(){
    int N, M, k, val, sum = 0, ans;

    array<int, 100> p;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        sum += p[i];
    }

    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> k >> val;
        cout << sum + val - p[k - 1] << '\n';
    }
    
}

Submission status: Runtime Error

Solution code:
num_problems = int(input())
a = input()
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)

Submission status: Runtime Error

Solution code:
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0
num_drinks = int(input())
for j in new:
  sum += int(j)

for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if new_line[1] != new[new_line[0]]:
    sum -= new[new_line[0]]
    sum += new_line[1]
  print(sum)

Submission status: Runtime Error

Solution code:
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0
num_drinks = input()
for j in new:
  sum += j

for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if new_line[1] != new[new_line[0]]:
    sum -= new[new_line[0]]
    sum += new_line[1]
  print(sum)

Submission status: Runtime Error

Solution code:
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0
num_drinks = input()
for j in new:
  sum += j

for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if new_line[1] != new[new_line[0]]:
    sum -= new[new_line[0]]
    sum += new_line[1]

Submission status: Runtime Error

Solution code:
ProNum = int(input())
time = input()
time = time.split()
TotalTime = 0

for t in time:
  TotalTime += int(t)
                  
DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time[int(line[0])])
  print(TotalTime+diff)

Submission status: Runtime Error

Solution code:
num_problems = int(input())
a = input()
seconds_per = a.split()
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  copy = seconds_per[question-1]
  seconds_per[question-1] = change
  print(sum(seconds_per))
  seconds_per[question-1] = copy

Submission status: Runtime Error

Solution code:
ProNum = int(input())
time = input()
time = time.split()
TotalTime = 0

for t in time:
  TotalTime += int(t)
                  
DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time(int(line[0])))
  print(TotalTime+diff)

Submission status: Runtime Error

Solution code:
ProNum = int(input())
time = input()
time = time.split()
TotalTime = 0

for t in time:
  TotalTime += t

DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time(int(line[0])))
  print(TotalTime+diff)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

m = int(input())

drink_num_time = []
drink_time = []

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

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[i])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
num_of_pro = raw_input()
problems = raw_input()
num_of_drinks = raw_input()
drinks_lines = []
count = 0
while count < int(num_of_drinks):
count += 1
each_line = raw_input()
drinks_lines.append(each_line)
for each_line in drinks_lines:
problem_num = [int(each_num) for each_num in problems.split()]
problem_num[int(each_line.split()[0]) -1] = int(each_line.split()[1])
print sum(problem_num)

Submission status: Runtime Error

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

t_sum = sum(T)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
    print(sum(T[:P-1])+X+sum(T[P:]))

Submission status: Runtime Error

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
T = IL()
s = sum(T)
M = IL()
for m,t in range(M):
  P(s-T[m]+t)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
t=[int(i)for i in input().split()]
m=int(input())
T=sum(t)
for i in' '*m:p,x=LI();print(T+x-t[p-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input().split())
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: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
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[i]+x
    print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readlines()

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

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
"""
in1 = '5'
in2 = '7 2 3 8 5'
in3 = '3'
in4 = ['4 2', '1 7', '4 13']

N = int(in1)
T_N = list(map(int, in2.split()))
M = int(in3)
P_M = [None] * M
X_M = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in in4[i].split())
"""
N = int(input())
T_N = list(map(int, input().split()))
M = int(input())
P_M = [None] * M
P_X = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in input().split())

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

Submission status: Runtime Error

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

N = int(input())
T_N = [int(input()) for _ in range(N)]
M = int(input())
for i in range(M):
    P_M, X_M = map(int, input().split())

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

Submission status: Runtime Error

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

N = int(input())
T_N = [int(input()) for _ in range(N)]
M = int(input())
for _ in range(M):
    P_M, X_M = map(int, input().split())

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

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict
import itertools
N = int(input())
town = [[int(i) for i in input().split(' ')] for _ in range(N)]

dist = 0
c = 0
for v in itertools.permutations(town,len(town)):
    c += 1
    sx = v[0][0]
    sy = v[0][1]
    for i in v[1::]:
        dist += math.sqrt((sx - i[0]) ** 2 + (sy - i[1]) ** 2)
        sx, sy = i[0], i[1]

print(dist/c)

Submission status: Runtime Error

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