Alice has recently received an array a_1, a_2, ..., a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!

However, soon Bob became curious, and as any sane friend would do, asked Alice to perform q operations of two types on her array:

  * 1 x y: update the element a_x to y (set a_x = y). 
  * 2 l r: calculate how many non-decreasing subarrays exist within the subarray [a_l, a_{l+1}, ..., a_r]. More formally, count the number of pairs of integers (p,q) such that l ≤ p ≤ q ≤ r and a_p ≤ a_{p+1} ≤ ... ≤ a_{q-1} ≤ a_q. 



Help Alice answer Bob's queries!

Input

The first line contains two integers n and q (1 ≤ n, q ≤ 2 ⋅ 10^5) — the size of the array, and the number of queries, respectively.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the elements of Alice's array.

The next q lines consist of three integers each. The first integer of the i-th line is t_i, the operation being performed on the i-th step (t_i = 1 or t_i = 2).

If t_i = 1, the next two integers are x_i and y_i (1 ≤ x_i ≤ n; 1 ≤ y_i ≤ 10^9), updating the element at position x_i to y_i (setting a_{x_i} = y_i).

If t_i = 2, the next two integers are l_i and r_i (1 ≤ l_i ≤ r_i ≤ n), the two indices Bob asks Alice about for the i-th query.

It's guaranteed that there is at least one operation of the second type.

Output

For each query of type 2, print a single integer, the answer to the query.

Example

Input


5 6
3 1 4 1 5
2 2 5
2 1 3
1 4 4
2 2 5
1 2 6
2 2 5


Output


6
4
10
7

Note

For the first query, l = 2 and r = 5, and the non-decreasing subarrays [p,q] are [2,2], [3,3], [4,4], [5,5], [2,3] and [4,5].
import java.io.*;
import java.util.*;

public class Div21567E {

	static long[][] t;
	static long[] a;
	
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st.nextToken());
		int q = Integer.parseInt(st.nextToken());
		a = new long[n];
		
		st = new StringTokenizer(br.readLine());
		
		for(int i = 0; i < n; i++)
			a[i] = Integer.parseInt(st.nextToken());
		
		t = new long[4 * n][7];
		
		build(1, 0, n-1);
		
		for(int i = 0; i < q; i++) {
			
			st = new StringTokenizer(br.readLine());
			int type = Integer.parseInt(st.nextToken());
			int xl = Integer.parseInt(st.nextToken());
			int yr = Integer.parseInt(st.nextToken());
			
			if(type == 1) {
				
				update(1, 0, n-1, xl-1, yr);
				
			}else {
				
				long[] res = sum(1, 0, n-1, xl-1, yr-1);
				
				if(res[6] == 1) {
					
					pw.println(res[4]);
					
				}else {
					
					pw.println((res[4] + (res[3] * (res[3] + 1) / 2)));
					
				}
				
				//pw.flush();
				
			}
			
		}

		pw.flush();
		pw.close();
		
	}
	
	//0 = leftmost val
	//1 = leftmost len
	//2 = rightmost val
	//3 = rightmost len
	//4 = left sub count (excluding right)
	//5 = right sub count (excluding left)
	//6 = 0 == broken, 1 == whole
	static void build(int v, int tl, int tr) {
	    if (tl == tr) {
	        t[v][0] = t[v][2] = a[tl];
	        t[v][1] = t[v][3] = t[v][4] = t[v][5] = t[v][6] = 1;
	        //System.out.println("Leaf: " + tl + " " + a[tl] + " | " + t[v][0] + " " + t[v][1] + " " + t[v][2] + " " + t[v][3] + " " + t[v][4] + " " + t[v][5] + " " + t[v][6]);
	    } else {
	        int tm = (tl + tr) / 2;
	        build(v*2, tl, tm);
	        build(v*2+1, tm+1, tr);
	        
	        //setting left and right most vals
	        t[v][0] = t[v*2][0];
	        t[v][2] = t[v*2+1][2];	        
	        //check to see if they decrease into each other
	        if(t[v*2][2] <= t[v*2+1][0]) {
	        	
	        	//System.out.println("Merging: " + t[v*2][2] + " " + t[v*2+1][0]);
	        	
	        	//create mid segment ERROR add parentheses around numb
	        	long midseg = (t[v*2][3] + t[v*2+1][1]) * (t[v*2][3] + t[v*2+1][1] + 1) / 2;
	        	
	        	//set temporary whole flag
	        	t[v][6] = 1;
	        	
	        	//check if left segment is whole
	        	if(t[v*2][6] == 1) {
	        		
	        		//if whole then add on additional length from right
	        		t[v][1] = t[v*2][3] + t[v*2+1][1];
	        		
	        		if(t[v*2+1][6] == 1) {
	        			
	        			t[v][4] = midseg;	        			
	        			
	        		}else {
	        			
	        			t[v][4] = midseg + t[v*2+1][4] - (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2);
	        			
	        		}
	        		
	        	}else {
	        		
	        		//otherwise set left length to outside length of left
	        		t[v][1] = t[v*2][1];
	        		//whole of segment cannot be true is part is not whole
	        		t[v][6] = 0;
	        		
	        		if(t[v*2+1][6] == 1) {
	        			
	        			t[v][4] = t[v*2][4];	        			
	        			
	        		}else {
	        			
	        			t[v][4] = t[v*2][4] + midseg + t[v*2+1][4] - (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2);
	        			
	        		}
	        			        		
	        	}
	        	
	        	//check if right segment is whole
	        	if(t[v*2+1][6] == 1) {
	        		
	        		//if whole then add on additional length from left
	        		t[v][3] = t[v*2][3] + t[v*2+1][1];
	        		
	        		if(t[v*2][6] == 1) {
	        			
	        			t[v][5] = midseg;	        			
	        			
	        		}else {
	        				        				  
	        			//error here for triang numb we are adding instead of mult
	        			t[v][5] = midseg + t[v*2][5] - (t[v*2][3] * (t[v*2][3] + 1) / 2);
	        			
	        			//System.out.println("Action: " + midseg + " " + t[v*2][3]);
	        			
	        		}
	        		
	        	}else {
	        		
	        		//otherwise set right length to outside length of right
	        		t[v][3] = t[v*2+1][3];
	        		//whole of segment cannot be true is part is not whole
	        		t[v][6] = 0;
	        		
	        		if(t[v*2][6] == 1) {
	        			
	        			t[v][5] = t[v*2+1][5];	        			
	        			
	        		}else {
	        			
	        			t[v][5] = t[v*2+1][5] + midseg + t[v*2][5] - (t[v*2][3] * (t[v*2][3] + 1) / 2);
	        			
	        		}
	        			        		
	        	}        	
	        	
	        }else {
	        	
	        	//set outside lengths
		        t[v][1] = t[v*2][1];
		        t[v][3] = t[v*2+1][3];
		        
		        //set broken
		        t[v][6] = 0;
		        
		        //set sums
		        
		        //System.out.println("Setting: " + t[v*2][4] + " " + t[v*2][6] + " " + t[v*2][3]);
		        
		        t[v][4] = t[v*2][4] + ((t[v*2][6] == 0) ? (t[v*2][3] * (t[v*2][3] + 1) / 2) : 0) + ((t[v*2+1][6] == 0) ? t[v*2+1][4] : 0);
		        t[v][5] = t[v*2+1][5] + ((t[v*2+1][6] == 0) ? (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2) : 0) + ((t[v*2][6] == 0) ? t[v*2][5] : 0);
	        	
	        }
	        
	        //System.out.println("Branch: " + tl + " " + tr + " | " + t[v][0] + " " + t[v][1] + " " + t[v][2] + " " + t[v][3] + " " + t[v][4] + " " + t[v][5] + " " + t[v][6]);
	        
	    }
	}
	
	static void update(int v, int tl, int tr, int pos, int new_val) {
	    if (tl == tr) {
	    	t[v][0] = t[v][2] = new_val;
	        t[v][1] = t[v][3] = 1;
	    } else {
	        int tm = (tl + tr) / 2;
	        if (pos <= tm)
	            update(v*2, tl, tm, pos, new_val);
	        else
	            update(v*2+1, tm+1, tr, pos, new_val);
	      //setting left and right most vals
	        t[v][0] = t[v*2][0];
	        t[v][2] = t[v*2+1][2];	        
	        //check to see if they decrease into each other
	        if(t[v*2][2] <= t[v*2+1][0]) {
	        	
	        	//create mid segment
	        	long midseg = (t[v*2][3] + t[v*2+1][1]) * (t[v*2][3] + t[v*2+1][1] + 1) / 2;
	        	
	        	//set temporary whole flag
	        	t[v][6] = 1;
	        	
	        	//check if left segment is whole
	        	if(t[v*2][6] == 1) {
	        		
	        		//if whole then add on additional length from right
	        		t[v][1] = t[v*2][3] + t[v*2+1][1];
	        		
	        		if(t[v*2+1][6] == 1) {
	        			
	        			t[v][4] = midseg;	        			
	        			
	        		}else {
	        			
	        			t[v][4] = midseg + t[v*2+1][4] - (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2);
	        			
	        		}
	        		
	        	}else {
	        		
	        		//otherwise set left length to outside length of left
	        		t[v][1] = t[v*2][1];
	        		//whole of segment cannot be true is part is not whole
	        		t[v][6] = 0;
	        		
	        		if(t[v*2+1][6] == 1) {
	        			
	        			t[v][4] = t[v*2][4];	        			
	        			
	        		}else {
	        			
	        			t[v][4] = t[v*2][4] + midseg + t[v*2+1][4] - (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2);
	        			
	        		}
	        			        		
	        	}
	        	
	        	//check if right segment is whole
	        	if(t[v*2+1][6] == 1) {
	        		
	        		//if whole then add on additional length from left
	        		t[v][3] = t[v*2][3] + t[v*2+1][1];
	        		
	        		if(t[v*2][6] == 1) {
	        			
	        			t[v][5] = midseg;	        			
	        			
	        		}else {
	        			
	        			t[v][5] = midseg + t[v*2][5] - (t[v*2][3] * (t[v*2][3] + 1) / 2);
	        			
	        		}
	        		
	        	}else {
	        		
	        		//otherwise set right length to outside length of right
	        		t[v][3] = t[v*2+1][3];
	        		//whole of segment cannot be true is part is not whole
	        		t[v][6] = 0;
	        		
	        		if(t[v*2][6] == 1) {
	        			
	        			t[v][5] = t[v*2+1][5];	        			
	        			
	        		}else {
	        			
	        			t[v][5] = t[v*2+1][5] + midseg + t[v*2][5] - (t[v*2][3] * (t[v*2][3] + 1) / 2);
	        			
	        		}
	        			        		
	        	}
	        	
	        	
	        	
	        }else {
	        	
	        	//set outside lengths
		        t[v][1] = t[v*2][1];
		        t[v][3] = t[v*2+1][3];
		        
		        //set broken
		        t[v][6] = 0;
		        
		        //set sums
		        t[v][4] = t[v*2][4] + ((t[v*2][6] == 0) ? (t[v*2][3] * (t[v*2][3] + 1) / 2) : 0) + ((t[v*2+1][6] == 0) ? t[v*2+1][4] : 0);
		        t[v][5] = t[v*2+1][5] + ((t[v*2+1][6] == 0) ? (t[v*2+1][1] * (t[v*2+1][1] + 1) / 2) : 0) + ((t[v*2][6] == 0) ? t[v*2][5] : 0);
	        	
	        }
	    }
	}

	static long[] sum(int v, int tl, int tr, int l, int r) {
	    if (l > r) 
	        return null;
	    if (l == tl && r == tr) {
	        return t[v];
	    }
	    int tm = (tl + tr) / 2;
	    
	    long[] sega = sum(v*2, tl, tm, l, Math.min(r, tm));
	    long[] segb = sum(v*2+1, tm+1, tr, Math.max(l, tm+1), r);
	    long[] segc = new long[7];
	    
	    if(sega == null)
	    	return segb;
	    
	    if(segb == null)
	    	return sega;
	    
	    //setting left and right most vals
	    segc[0] = sega[0];
	    segc[2] = segb[2];	        
        //check to see if they decrease into each other
        if(sega[2] <= segb[0]) {
        	
        	//create mid segment
        	long midseg = (sega[3] + segb[1]) * (sega[3] + segb[1] + 1) / 2;
        	
        	//set temporary whole flag
        	segc[6] = 1;
        	
        	//check if left segment is whole
        	if(sega[6] == 1) {
        		
        		//if whole then add on additional length from right
        		segc[1] = sega[3] + segb[1];
        		
        		if(segb[6] == 1) {
        			
        			segc[4] = midseg;	        			
        			
        		}else {
        			
        			segc[4] = midseg + segb[4] - (segb[1] * (segb[1] + 1) / 2);
        			
        		}
        		
        	}else {
        		
        		//otherwise set left length to outside length of left
        		segc[1] = sega[1];
        		//whole of segment cannot be true is part is not whole
        		segc[6] = 0;
        		
        		if(segb[6] == 1) {
        			
        			segc[4] = sega[4];	        			
        			
        		}else {
        			
        			segc[4] = sega[4] + midseg + segb[4] - (segb[1] * (segb[1] + 1) / 2);
        			
        		}
        			        		
        	}
        	
        	//check if right segment is whole
        	if(segb[6] == 1) {
        		
        		//if whole then add on additional length from left
        		segc[3] = sega[3] + segb[1];
        		
        		if(sega[6] == 1) {
        			
        			segc[5] = midseg;	        			
        			
        		}else {
        			
        			segc[5] = midseg + sega[5] - (sega[3] * (sega[3] + 1) / 2);
        			
        		}
        		
        	}else {
        		
        		//otherwise set right length to outside length of right
        		segc[3] = segb[3];
        		//whole of segment cannot be true is part is not whole
        		segc[6] = 0;
        		
        		if(sega[6] == 1) {
        			
        			segc[5] = segb[5];	        			
        			
        		}else {
        			
        			segc[5] = segb[5] + midseg + sega[5] - (sega[3] * (sega[3] + 1) / 2);
        			
        		}
        			        		
        	}
        	
        	
        	
        }else {
        	
        	//set outside lengths
        	segc[1] = sega[1];
        	segc[3] = segb[3];
	        
	        //set broken
        	segc[6] = 0;
	        
	        //set sums
        	segc[4] = sega[4] + ((sega[6] == 0) ? (sega[3] * (sega[3] + 1) / 2) : 0) + ((segb[6] == 0) ? segb[4] : 0);
	        segc[5] = segb[5] + ((segb[6] == 0) ? (segb[1] * (segb[1] + 1) / 2) : 0) + ((sega[6] == 0) ? sega[5] : 0);
        	
        }
        
        return segc;
	    
	}
	
}
