Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(max(n, m)):
  print(s - t[p[j]] + x[j])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(int(s - t[p[j]] + x[j]))

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
s = sum(t)
for j in range(m):
  print(int(s - t[p[j]] + x[j]))

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
s = sum(t)
for j in range(m):
  print(s - t[p[j]] + x[j])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[p[j]] + x[j])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[j] + x[j])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[i] + x[i])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])

Buggy python submission (verdict: Runtime Error):
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(sum - t[i] + x[i])

Fixed submission:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])