from collections import deque n = int(input()) a = list(map(int, input().split())) q = int(input()) for _ in range(q): x, b = map(int, input().split()) x -= 1 visited = [False] * n queue = deque([x]) visited[x] = True total = 0 while queue: current = queue.popleft() total += a[current] for next in [current - 1, current + 1]: if 0 <= next < n and not visited[next] and a[next] > 0: visited[next] = True queue.append(next) print(total + b - a[x])