You have an array of elements. An array of elements has prefix.

Prefix-1 has only the first element of the array.

Prefix-2 has the first two elements of the array.

Prefix-3 has the first three elements of the array

………..

Prefix-n-1 has the first n-1 elements of the array.

Prefix-n has the first n elements of the array.

There are also queries. In each query given two values and . You have to set into position in the array and print the maximum prefix sum among prefixes.

Input Format

First line of input contains and — length of the array and number of query.

Second line contains integers — initial value of the array.

Next line contains two integer and . You have to set into position in the array.

Constraints

Output Format

Print line one integer maximum prefix sum after each query.

Sample Input 0

3 3
10 -11 8
2 -12
2 -25
3 30

Sample Output 0

10
10
15

Explanation 0

After first query array look like [10,-12,8] and maximum prefix sum 10.

After second query array look like [10,-25,8] and maximum prefix sum 10.

After third query array look like [10,-25,30] and maximum prefix sum 15=10-25+30.

Line: 1 Col: 1
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score