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].
// Don't place your source in a package


import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;



// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

        long Long() {
            return Long.parseLong(next());
        }

        String Str(){
            return next();
        }
    }


    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        //reading /writing file
        //Scanner sc=new Scanner(new File("src/text.txt"));
        //PrintWriter pr=new PrintWriter("output.txt");
        //File file = new File("src/text.txt");



        int T=1;
        for(int t=0;t<T;t++){
            int n=Int();int m=Int();
            int A[]=Arr(n);
            int q[][]=new int[m][3];
            for(int i=0;i<q.length;i++){
                for(int j=0;j<3;j++){
                    q[i][j]=Int();
                }
            }

            Solution sol1=new Solution(out);
            sol1.solution(A,q);
        }
        out.close();

    }


    public static int[] Arr(int n){
        int A[]=new int[n];
        for(int i=0;i<n;i++)A[i]=Int();
        return A;
    }
    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}








class Solution {
    PrintWriter out;
    int INF = Integer.MAX_VALUE;
    int MOD = 1000000007;
    long mod = 1000000007;

    public Solution(PrintWriter out) {
        this.out = out;
    }


    int A[];
    public void solution(int A[],int q[][]) {
        this.A=A;
        Seg seg=new Seg(0,A.length-1);
        for(int i=0;i<q.length;i++){
            int opt = q[i][0];
            if(opt==1){
                int index=q[i][1]-1;
                int y= q[i][2];
                A[index]=y;
                seg.update(index,y);
            }
            else{
                int l =q[i][1]-1;
                int r=q[i][2]-1;
                long p[]=seg.query(l,r);
                out.println(p[2]);
            }
        }

    }

    public long cal(long n){
        return n*(1+n)/2;
    }

    class Seg{
        int l,r;
        int pre = 0, post = 0;
        long sum = 0;
        long size = 0;
        Seg left=null,right=null;
        boolean is=false;
        public Seg(int l,int r){
            this.l=l;
            this.r=r;
            this.size=r-l+1;
            if(l!=r){
                int mid=l+(r-l)/2;
                if(l<=mid)left=new Seg(l,mid);
                if(r>=mid+1)right=new Seg(mid+1,r);

                this.sum+=right.sum;
                this.sum+=left.sum;

                if(A[mid+1]>=A[mid]){//can merge
                    if(left.is&&right.is){
                        this.is=true;
                        this.pre=(int)(size);
                        this.post=(int)(size);
                        this.sum= cal(size);
                    }
                    else if(left.is&&!right.is){
                        this.is=false;
                        this.pre=left.post+right.pre;
                        this.post=right.post;
                        this.sum-=cal(left.post);
                        this.sum-=cal(right.pre);
                        this.sum+=cal(left.post+right.pre);
                    }
                    else if(!left.is&&right.is){
                        this.is=false;
                        this.post=left.post+right.pre;
                        this.pre=left.pre;
                        this.sum-=cal(left.post);
                        this.sum-=cal(right.pre);
                        this.sum+=cal(left.post+right.pre);
                    }
                    else{
                        this.is=false;
                        this.pre=left.pre;
                        this.post=right.post;
                        this.sum-=cal(left.post);
                        this.sum-=cal(right.pre);
                        this.sum+=cal(left.post+right.pre);
                    }
                }else{
                    this.pre=left.pre;
                    this.post=right.post;
                }
            }
            else{
                pre = 1;
                post = 1;
                sum = 1;
                is = true;
            }
        }

        public long[] query(int s,int e){
            //if(e<0||s<0)return 0;
            if(l==s&&r==e){
                int iss=1;
                if(!this.is)iss=0;
                return new long[]{this.pre,this.post,this.sum,iss};
            }
            int mid=l+(r-l)/2; //left :  to mid-1,
            if(e<=mid){
                return left.query(s,e);
            }
            else if(s>=mid+1){
                return right.query(s,e);
            }else{
                long p1[] = left.query(s,mid);
                long p2[]= right.query(mid+1,e);
                long res = p1[2]+p2[2];

                //[s:mid]
                //[mid+1:e]

                if(A[mid+1]>=A[mid]){//can merge
                    if(p1[3]==1l&&p2[3]==1l){
                        res=cal(e-s+1);
                        return new long[]{e-s+1,e-s+1,res,1};
                    }
                    else if(p1[3]==1l&&p2[3]!=1l){
                        res-=cal(p1[1]);
                        res-=cal(p2[0]);
                        res+=cal(p1[1]+p2[0]);
                        return new long[]{p1[1]+p2[0],p2[1],res,0};
                    }
                    else if(p1[3]!=1l&&p2[3]==1l){
                        res-=cal(p2[0]);
                        res-=cal(p1[1]);
                        res+=cal(p1[1]+p2[0]);
                        return new long[]{p1[0],p1[1]+p2[0],res,0};
                    }
                    else{
                        res-=cal(p1[1]);
                        res-=cal(p2[0]);
                        res+=cal(p1[1]+p2[0]);
                        return new long[]{p1[0],p2[1],res,0};
                    }
                }else{
                    return new long[]{p1[0],p2[1],res,0};
                }

            }
        }

        public void update(int index,int val){
            if(l==r){
                return;
            }
            this.is=false;
            int mid=l+(r-l)/2;
            if(index<=mid){
                left.update(index,val);
            }else{
                right.update(index,val);
            }


            this.sum=right.sum+left.sum;
            if(A[mid+1]>=A[mid]){//can merge
                if(left.is&&right.is){
                    this.is=true;
                    this.pre=(int)(size);
                    this.post=(int)(size);
                    this.sum= cal(size);
                }
                else if(left.is&&!right.is){
                    this.is=false;
                    this.pre=left.post+right.pre;
                    this.post=right.post;
                    this.sum-=cal(left.post);
                    this.sum-=cal(right.pre);
                    this.sum+=cal(left.post+right.pre);
                }
                else if(!left.is&&right.is){
                    this.is=false;
                    this.post=right.pre+left.post;
                    this.pre=left.pre;
                    this.sum-=cal(right.pre);
                    this.sum-=cal(left.post);
                    this.sum+=cal(left.post+right.pre);
                }
                else{
                    this.is=false;
                    this.pre=left.pre;
                    this.post=right.post;
                    this.sum-=cal(left.post);
                    this.sum-=cal(right.pre);
                    this.sum+=cal(left.post+right.pre);
                }
            }else{
                this.pre=left.pre;
                this.post=right.post;
            }
        }
    }

}
