#SGM0000014. Truy vấn tổng đoạn con (Subarray Sum Queries)

Truy vấn tổng đoạn con (Subarray Sum Queries)

Subarray Sum Queries

Source: CSES

Version: Phuoc Hung OJ Extended

You are given an array of NN integers and QQ point updates. An update gives k,xk,x and assigns Ak=xA_k=x. After each update, print the maximum contiguous subarray sum of the whole array.

The empty subarray with sum 00 is allowed.

Input

The first line contains N,QN,Q.

The second line contains A1,…,ANA_1,\ldots,A_N.

Each of the next QQ lines contains k,xk,x.

Output

After every update, print the maximum subarray sum.

Subtasks

  • Subtask 1 — 20%: 1≤N,Q≤501\le N,Q\le 50, ∣Ai∣,∣x∣≤104|A_i|,|x|\le 10^4.
  • Subtask 2 — 30%: 1≤N,Q≤50001\le N,Q\le 5000, ∣Ai∣,∣x∣≤109|A_i|,|x|\le 10^9.
  • Subtask 3 — 50%: 1≤N,Q≤2⋅1051\le N,Q\le 2\cdot 10^5, ∣Ai∣,∣x∣≤109|A_i|,|x|\le 10^9.

Examples

Input

5 3
1 2 -3 5 -1
2 6
3 1
2 -2

Output

9
13
6

Explanation

The sample follows the operations exactly; each printed line corresponds to a query that requires output.