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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
test = list(map(int,input()))

for _ in range(input()):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
T=[int(i) for i in raw_input().split()]
M=int(input())
PX=[]
for i in range(M):
    PX.append([int(k) for k in raw_input().split()])
if N>=M:
    for h in range(M):
        time=sum(T)-(T[PX[h][0]-1]-PX[h][1])
        print(time)
else:
    for h in range(N):
        time=sum(T)-(T[PX[h][0]-1]-PX[h][1])
        print(time)

Submission status: Runtime Error

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

for h in range(M):
    time=sum(T)-(T[PX[h][0]-1]-PX[h][1])
    print(time)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
# 入力
N=int(input())
tl=list(map(int,input().split()))
M=int(input())

# 和
sm=sum(tl)

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

  # 変更した場合の変化量を求める
  a=X-tl[P-1]

  # 解答を保存
  al.append(sm+a)

# 出力
for x in al:
  print(x)

Submission status: Runtime Error

Solution code:
# 入力
N=int(input())
tl=list(map(int,input().split()))
M=int(input())

# 和
sm=sum(tl)

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

  # 変更した場合の変化量を求める
  a=X-tl[P-1]

  # 出力
  print(sm+a)

Submission status: Runtime Error

Solution code:
N = int(input())
#N = int(line)
#line = test_data.readline()
T = [int(t) for t in input().split()]
#T = [2,1,4]
#T = [int(t) for t in test_data.readline().split()]
total_time = sum(T)
#line = test_data.readline()
M = int(input())
#M = int(line)
for i in range(M):
	#line = test_data.readline()
	P, X = map(int,input().split())
	#P, X = map(int,line.split())
	ans = 0
	ans = total_time - T[i] + X
	print(ans)

Submission status: Runtime Error

Solution code:
N = input()
#N = int(line)
#line = test_data.readline()
#T = [int(t) for t in input().split()]
T = [2,1,4]
#T = [int(t) for t in test_data.readline().split()]
total_time = sum(T)
#line = test_data.readline()
M = input()
#M = int(line)
for i in range(M):
	#line = test_data.readline()
	P, X = input().split()
	#P, X = map(int,line.split())
	ans = 0
	ans = total_time - T[i] + X
	print(ans)

Submission status: Runtime Error

Solution code:
# ファイルをオープンする
#test_data = open("test.txt", "r")

# 行ごとにすべて読み込んでリストデータにする
#line = test_data.readline()


N = input()
#N = int(line)
#line = test_data.readline()
T = [int(t) for t in input().split()]
#T = [int(t) for t in test_data.readline().split()]
total_time = sum(T)
#line = test_data.readline()
M = input()
#M = int(line)
for i in range(M):
	#line = test_data.readline()
	P, X = input().split()
	#P, X = map(int,line.split())
	ans = 0
	ans = total_time - T[i] + X
	print(ans)

Submission status: Runtime Error

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

for i in range(M):
	P, X = input().split()
	ans = 0
	ans = total_time - T[i] + X
	print(ans+"¥n")

Submission status: Runtime Error

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

for i in range(M):
	P, X = input().split()
	ans = 0
	ans = total_time - N[i] + X
	print(ans+"¥n")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(M):
    x,y = map(int,input().split())
    a[0] = x
    a[1] = y
    print(sum(a))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(1,m+1):
  x=listA[listB[i][0]]
  listA[listB[i][0]] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]]=x

Submission status: Runtime Error

Solution code:
n = int(input())
listA = list(int, input().split())
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(1,m+1):
  x=listA[listB[i][0]]
  listA[listB[i][0]] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]]=x

Submission status: Runtime Error

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

ans = sum(tt)
for i in range(m):
    print(ans - (tt[i] - drinks[i][1]))

Submission status: Runtime Error

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

for i in range(M):
    print(sum(Tlist)-Tlist[i]+PX[i][1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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())
    s=0
    for j in range(len(t)):
        if j==p-1:
            s+=x
        else:
            s+=t[j]
    print(s)

Submission status: Runtime Error

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

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

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

Submission status: Runtime Error

Solution code:
n = int(input())
*a0, = map(int, input().split())
m = int(input())
for _ in range(m):
    k, b = map(int, input().split())
    a = a0[:]
    a[k] = b
    print(sum(a))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def execute(n, tn, m, pxm):
    result = []
    for px in pxm:
        cp = tn[:]
        cp[px[0] - 1] = px[1]
        result.append(sum(cp))
    return result


if __name__ == '__main__':
    n = int(input())
    tn = map(int, input().split())
    m = int(input())
    pxm = []
    for _ in range(m):
        p, x = map(int, input().split())
        pxm.append([p, x])
    print(execute(n, tn, m, pxm))

Submission status: Runtime Error

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

M  = int(input())
PX = [int(input()) for _ in range(M)]

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

Submission status: Runtime Error

Solution code:
N = int(input())
Problems = list(map(int,input().split()))
results = []
M = int(input())
for i in range(M):
  	temPro = Problems
    p,t = map(int,input().split())
    temPro[p-1] = t

    print(sum(temPro))

Submission status: Runtime Error

Solution code:
N = int(input())
Problems = list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,t = map(int,input().split())
    Problems[p] = t
    print(sum(Problems))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
m = int(input())
D = list(map(int, input().split()))
for i, d in enumerate(D):
  print(sumT - T[i] + d)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(m-1):
    print(maxn[i])

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 入力
N = int(input())
T = map(int, input().split())
M = int(input())
for i in range(0, M):
    p, x = map(int, input().split())
    Time = sum(T) - T[p - 1] + x
    print(Time)

Submission status: Runtime Error

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

s = sum(t)

for i in range(m):
    p.append(input().split())

if n<=m:
    for i in range(m):
        print(s-t[i]+int(p[i][1]))
else:
    for i in range(n):
        print(s-t[i]+int(p[i][1]))
    for i in range(n-m):
        print(s)

Submission status: Runtime Error

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

s = sum(t)

for i in range(m):
    p.append(input().split())

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

Submission status: Runtime Error

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

s = sum(t)

for i in range(m):
    p.append(input().split())

for i in range(m):
    print(s-t[i]+p[i])

Submission status: Runtime Error

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

s = sum(t)

for i in range(m):
    p.attend(input().split())

for i in range(m):
    print(s-t[i]+p[i])

Submission status: Runtime Error

Solution code:
n = int(input())
t = [0] + list(map(int,input().split()))
s = sum(t)
for _ in [0]*int(input()):
  p,x = map(int,input().split())
  pritn(s-t[p]+x)

Submission status: Runtime Error

Solution code:
N = int(input())
Ts = input().split()
Ts = [int(i) for i in Ts]
Tsum = sum(Ts)
M = int(input())
res_list = []
for i in range(M):
    P,X = map(int,input().split())
    res = Tsum - Ts[i] + X
    res_list.append(res)
for i in res_list:
    print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

using namespace std;

int main(){
  int n;
  cin >> n;
  int t[n];
  int sum;
  for(int i=0; i<n; i++){
    cin >> t[i];
    sum += t[i];
  }
  int m;
  cin >> m;
  int p,x;
  for(int i=0; i<m; i++){
    cin >> p >> x;
    cout << sum-t[p-1]+x << endl;
  }
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = list(map(int, input().split()))      
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

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

for k in range(M):
   a = list(map(int, input().split()))      
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input().split()) for i in range(N)]
 
M = int(input())
 
a = []
for k in range(M):
    a.append(map(int, input()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input().split()) for i in range(N)]
 
M = int(input())
 
a = []
for k in range(M):
    a.append(map(int, input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for k in range(M):
    a.append(map(int, input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for i in range(2):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [input() for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())
 
t = [input() for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])
N = int(input())
 
t = [input() for i in range(N)]
 
M = int(input())
 
a = []
for i in range(M):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])

Submission status: Runtime Error

Solution code:
N = int(input())

t = [input() for i in range(N)]

M = input()

a = []
for i in range(M):
    a.append(map(int, raw_input().split()))       #a=[[P1 X1]みたいな]

cal = sum(t)

for j in range(M):
    print(cal - t[a[j][0]] + a[j][1])

Submission status: Runtime Error

Solution code:
#50b
#n　問題数
n = int(input())
#t 時間
t = [int(i) for i in input().split()]
#m ドリンクの種類
m = int(input())
ans = []
for i in range(m):
    a,b = map(int,input().split())
    temp = sum(t) - t[a-1] + b
    ans[i] = temp
for i in range(m):
    print(ans[i])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for k in range(M):
    p,x = (int(i) for i in input().split())
    time.append（total - T[p] + x)

print(time)

Submission status: Runtime Error

Solution code:
N = int(input())

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for i in range(M):
    p,x = (int(i) for i in input().split())
    time.append（total - T[p] + x)

print(time)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

void chmax(int &a,int b) { a=max(a,b); }
void chmin(int &a,int b) { a=min(a,b); }

//-----------------------------------------------------------------------------

int n,m;
int sum;
int t[100];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	REP(i,n) {
		cin>>t[i];
		sum+=t[i];
	}
	cin>>m;
	REP(i,m) {
		int p,x;cin>>p>>x;p--;
		cout<<sum-t[p]+x<<endl;
	}

	return 0;
}

Submission status: Runtime Error

Solution code:

    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: Runtime Error

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_copy)
        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: Runtime Error

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


print(main())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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(' ')
    print sum(line)-(line[x[0]]-x[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
T = map(int,input().split())
M = int(input())
p = []
x = []
TIME = 0
for i in range(M):
    pi,xi = map(int,input().split())
    p.append(pi)
    x.append(xi)
for n in range(len(T)):
    TIME = TIME + T[n]
for i in range(M):
    print(TIME - T[p[i]] + x[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

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