In the geometry class, Ulugbek learned about the triangle inequality. For three sticks of length $$$x$$$, $$$y$$$, and $$$z$$$ meters, the following properties should be held: $$$x+y \gt z$$$, $$$x+z \gt y$$$, and $$$y+z \gt x$$$. The perimeter of this triangle equals $$$x+y+z$$$ meters.
There are $$$n$$$ sticks of length $$$a[0], a[1], \ldots, a[n-1]$$$ meters. Ulugbek gives you $$$q$$$ queries of two types:
The first line contains $$$n$$$ and $$$q$$$. ($$$1 \le n, q \le 2 \cdot 10^5$$$)
The second line contains $$$a[0], a[1], \ldots, a[n-1]$$$. ($$$1 \le a[i] \le 5 \cdot 10^8$$$).
The next $$$q$$$ lines contain queries of either type $$$0 \; p \; v$$$ or $$$1 \; l \; r$$$. ($$$0 \le p \le n - 1$$$, $$$1 \le v \le 5 \cdot 10^8$$$), ($$$0 \le l \le r \le n - 1$$$).
For each query of type $$$1 \; l \; r$$$, print the largest possible perimeter using sticks in the range $$$[l, r]$$$, or print $$$0$$$ if it is impossible to create a triangle.
| Group | Add. constraints | Points |
| $$$0$$$ | examples | $$$0$$$ |
| $$$1$$$ | $$$n, q \le 80$$$ | $$$3$$$ |
| $$$2$$$ | $$$n, q \le 400$$$ | $$$7$$$ |
| $$$3$$$ | $$$n, q \le 3000$$$ | $$$16$$$ |
| $$$4$$$ | All values of $$$a[i]$$$ and $$$v$$$ are integer powers of $$$2$$$. | $$$15$$$ |
| $$$5$$$ | There are no queries of type $$$0 \; p \; v$$$ | $$$16$$$ |
| $$$6$$$ | $$$a[i], v \le 10^5$$$ | $$$20$$$ |
| $$$7$$$ | $$$n \le 5 \cdot 10^4$$$ | $$$10$$$ |
| $$$8$$$ | — | $$$13$$$ |
7 3 3 1 4 1 5 9 2 1 2 6 0 0 7 1 0 2
11 0
For query $$$l=2$$$ and $$$r=6$$$, we can use sticks $$$a[2] = 4$$$, $$$a[4] = 5$$$, and $$$a[6] = 2$$$. The perimeter equals $$$4+5+2=11$$$.
Then, we are asked to set $$$a[0] := 7$$$. Now, $$$a=[7, 1, 4, 1, 5, 9, 2]$$$.
In the next query, $$$l=0$$$ and $$$r=2$$$. The only triplet is $$$(7, 1, 4)$$$, which doesn't follow the triangle inequality. Thus, the answer is $$$0$$$.
| Name |
|---|


