100 atcoder#ABC050B. [ABC050B] Contest with Drinks Easy

[ABC050B] Contest with Drinks Easy

Score : 200200 points

Problem Statement

Joisino is about to compete in the final round of a certain programming competition. In this contest, there are NN problems, numbered 11 through NN. Joisino knows that it takes her TiT_i seconds to solve problem i(1iN)i(1 \leq i \leq N).

Also, there are MM kinds of drinks offered to the contestants, numbered 11 through MM. If Joisino takes drink i(1iM)i(1 \leq i \leq M), her brain will be stimulated and the time it takes for her to solve problem PiP_i will become XiX_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.
  • 1N1001 \leq N \leq 100
  • 1Ti1051 \leq T_i \leq 10^5
  • 1M1001 \leq M \leq 100
  • 1PiN1 \leq P_i \leq N
  • 1Xi1051 \leq X_i \leq 10^5

Input

The input is given from Standard Input in the following format:

NN

T1T_1 T2T_2 ...... TNT_N

MM

P1P_1 X1X_1

P2P_2 X2X_2

::

PMP_M XMX_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.

3
2 1 4
2
1 1
2 3
6
9

If Joisino takes drink 11, the time it takes her to solve each problem will be 11, 11 and 44 seconds, respectively, totaling 66 seconds.

If Joisino takes drink 22, the time it takes her to solve each problem will be 22, 33 and 44 seconds, respectively, totaling 99 seconds.

5
7 2 3 8 5
3
4 2
1 7
4 13
19
25
30