/*

Problem Statement

Joisino is about to compete in the final round of a certain programming competition. In this contest, there are problems, numbered through . Joisino knows that it takes her seconds to solve problem .

Also, there are kinds of drinks offered to the contestants, numbered through . If Joisino takes drink , her brain will be stimulated and the time it takes for her to solve problem will become 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.

Input

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







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.

Sample Input 1

3
2 1 4
2
1 1
2 3

Sample Output 1

6
9

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

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

Sample Input 2

5
7 2 3 8 5
3
4 2
1 7
4 13

Sample Output 2

19
25
30 */ #include <iostream> using namespace std;
#define h 100100 int t[h]; int main()
{
    int n;
    cin >> n;
int i = 1;
    while(n --)
    {
        cin >> t[i];
        i ++;
    }
    int m;
    cin >> m;
    while(m --)
    {
        int p, x;
        cin >> p >> x;
        int c;
        c = t[p];
        t[p] = x;
        int sum = 0;
        for(int j = 1; j < i; j ++)
        {
            sum += t[j];
        }
        cout << sum <<endl;
        t[p] = c;
    }
    return 0;
}
04-16 14:53
查看更多