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):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(M):
    count = c
    count += X[i]
    count -= T[P[i]]
    print(count)

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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

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):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(len(X)):
    count = c
    count += X[i]
    count -= T[i]
    print(count)

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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

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):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(len(X)):
    count = c
    count += X[i]
    count -= T[i]
    print(count

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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

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):
    pi, xi = map(int, input().split)
    P.append(pi)
    X.append(xi)

count = 0
for i in T:
    count += T[i]

for i in X:
    count += X[i]
    count -= T[i]
    print(count

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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

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):
    p1, x1 = map(int, input().split)
    P.append(p1)
    X.append(x1)

count = 0
for i in T:
    count += T[i]

discount = 0
for i in T:
    if i <= M:
        discount += T[i]

special = 0
for i in P, X:
    special += P[i]
    special += X[i]

count *= M
count -= discount
count += special

print(count)

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

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