N = int(input())
A = list(map(int, input().split()))
Q = int(input())

import numpy as np
numbers = np.arange(1, 1e5, 1)
A = np.array(A)
ans = []

for i in range(Q):
    B, C = map(int, input().split())
    numbers[B-1] = C
    tempA = A
    for i in range(N):
        tempA[i] = numbers[A[i]-1]
    ans.append(np.sum(A))

for i in ans:
    print(i)