#K77852. Resource Management and Score Updates

    ID: 34956 Type: Default 1000ms 256MiB

Resource Management and Score Updates

Resource Management and Score Updates

You are given an array of n resource units. The initial resource score is defined as the sum of all resource units modulo \(10^9+7\). You will be given m update operations. In each update, you are given a 1-indexed position and a new value. Replace the resource unit at that position with the new value and then compute the new resource score (i.e. the sum of the updated array modulo \(10^9+7\)).

Your task is to output the initial resource score followed by the resource score after each update, all in one line, separated by a single space.

Example:

Input:
3
1 2 3
2
2 5
1 6

Output: 6 9 14

</p>

inputFormat

The input is given from standard input (stdin) in the following format:

  1. The first line contains an integer n representing the number of resource units.
  2. The second line contains n space-separated integers representing the resource units.
  3. The third line contains an integer m representing the number of update operations.
  4. The following m lines each contain two space-separated integers index and new_value, where index is the 1-indexed position of the resource to update.

outputFormat

Print a single line to standard output (stdout) containing m+1 space-separated integers: the initial resource score followed by the updated resource scores after each operation. The score is computed as the sum of the resource units modulo \(10^9+7\).

## sample
3
1 2 3
0
6