D. k-Maximum Subsequence Sum
time limit per test
4 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Consider integer sequence a 1, a 2, ..., a n. You should run queries of two types:

• The query format is "0 i val". In reply to this query you should make the following assignment: a i = val.
• The query format is "1 l r k". In reply to this query you should print the maximum sum of at most k non-intersecting subsegments of sequence a l, a l + 1, ..., a r. Formally, you should choose at most k pairs of integers (x 1, y 1), (x 2, y 2), ..., (x t, y t) (l ≤ x 1 ≤ y 1 < x 2 ≤ y 2 < ... < x t ≤ y t ≤ rt ≤ k) such that the sum a x 1 + a x 1 + 1 + ... + a y 1 + a x 2 + a x 2 + 1 + ... + a y 2 + ... + a x t + a x t + 1 + ... + a y t is as large as possible. Note that you should choose at most k subsegments. Particularly, you can choose 0 subsegments. In this case the described sum considered equal to zero.
Input

The first line contains integer n (1 ≤ n ≤ 105), showing how many numbers the sequence has. The next line contains n integers a 1, a 2, ..., a n (|a i| ≤ 500).

The third line contains integer m (1 ≤ m ≤ 105) — the number of queries. The next m lines contain the queries in the format, given in the statement.

All changing queries fit into limits: 1 ≤ i ≤ n, |val| ≤ 500.

All queries to count the maximum sum of at most k non-intersecting subsegments fit into limits: 1 ≤ l ≤ r ≤ n, 1 ≤ k ≤ 20. It is guaranteed that the number of the queries to count the maximum sum of at most k non-intersecting subsegments doesn't exceed 10000.

Output

For each query to count the maximum sum of at most k non-intersecting subsegments print the reply — the maximum sum. Print the answers to the queries in the order, in which the queries follow in the input.

Examples
Input
99 -8 9 -1 -1 -1 9 -8 931 1 9 11 1 9 21 4 6 3
Output
17250
Input
15-4 8 -3 -10 10 4 -7 -7 0 -6 3 8 -10 7 2151 3 9 21 6 12 10 6 50 10 -71 4 9 11 7 9 10 10 -31 4 10 21 3 13 21 4 11 20 15 -90 13 -90 11 -101 5 14 21 6 12 1
Output
1411150152618238
Note

In the first query of the first example you can select a single pair (1, 9). So the described sum will be 17.

Look at the second query of the first example. How to choose two subsegments? (1, 3) and (7, 9)? Definitely not, the sum we could get from (1, 3) and (7, 9) is 20, against the optimal configuration (1, 7) and (9, 9) with 25.

The answer to the third query is 0, we prefer select nothing if all of the numbers in the given interval are negative.