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].
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
#define read(x)  freopen("input.txt","r",stdin);
#define iter(x)  x.begin(),x.end()
#define ll long long
#define ull unsigned ll
#define endl '\n'
#define inf INT_MAX
#define mod 1000000007
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


const int RIGHT = 2*131072;
const int SIZE = 2*255005;
int N, Q, K[SIZE], D[SIZE], LK[SIZE], LD[SIZE], S[SIZE];

void build(int n,int b,int e,vector<int>&v)
{
    if(b==e)
        S[n]=v[b];
    else
    {
        build(2*n,b,(b+e)/2,v);
        build(2*n+1,(b+e)/2+1,e,v);
        S[n]=S[2*n]+S[2*n+1];

    }
}

int query(int l, int r, int n = 1, int a = 1, int b = RIGHT)
{
    if(a > r || b < l) return 0;
    if(a >= l && b <= r) return S[n];

    if(LK[n] != 0 || LD[n] != 0)
    {
        int sz = (b-a+1) / 2;
        K[2*n] += LK[n], K[2*n+1] += LK[n] + LD[n]*sz;
        D[2*n] += LD[n], D[2*n+1] += LD[n];
        S[2*n] += LK[n]*sz + LD[n]*sz*(sz-1) / 2;
        S[2*n+1] += (LK[n] + LD[n]*sz)*sz + LD[n]*sz*(sz-1) / 2;
        LK[2*n] += LK[n], LK[2*n+1] += LK[n] + LD[n]*sz;
        LD[2*n] += LD[n], LD[2*n+1] += LD[n];
        LK[n] = LD[n] = 0;
    }

    int mid = (a+b) / 2;
    return query(l,r,2*n,a,mid) + query(l,r,2*n+1,mid+1,b);
}

void update(int l, int r, int k=1, int d=1, int n = 1, int a = 1, int b = RIGHT)
{
    if(a >= l && b <= r)
    {
        K[n] += k, D[n] += d;
        LK[n] += k, LD[n] += d;
        int sz = (b-a+1);
        S[n] += k*sz + d*sz*(sz-1) / 2;
        return;
    }

    if(LK[n] != 0 || LD[n] != 0)
    {
        int sz = (b-a+1) / 2;
        K[2*n] += LK[n], K[2*n+1] += LK[n] + LD[n]*sz;
        D[2*n] += LD[n], D[2*n+1] += LD[n];
        S[2*n] += LK[n]*sz + LD[n]*sz*(sz-1) / 2;
        S[2*n+1] += (LK[n] + LD[n]*sz)*sz + LD[n]*sz*(sz-1) / 2;
        LK[2*n] += LK[n], LK[2*n+1] += LK[n] + LD[n]*sz;
        LD[2*n] += LD[n], LD[2*n+1] += LD[n];
        LK[n] = LD[n] = 0;
    }

    int mid = (a+b) / 2;
    if(l <= mid) update(l,min(mid,r),k,d,2*n,a,mid);
    if(r > mid) update(max(mid+1,l),r,k + d*max(mid-l+1,0),d,2*n+1,mid+1,b);

    S[n] = S[2*n] + S[2*n+1];
}

/*void update(int n,int b,int e,int i,int j,int val)
{
    if(e<i or b>j)
        return;
    if(b>=i and e<=j)
    {
        lazy[n]+=val;
    }
    update(2*n,b,(b+e)/2,i,j,val);
    update(2*n+1,(b+e)/2+1,e,i,j,val);

}
int get_sum(int n,int b,int e,int i,int j,int carry=0)
{

    if(e<i or b>j)
        return 0;
    if(b>=i and e<=j)
    {
        return t[n]+(carry+lazy[n])*(e-b+1);
    }
    int p1=get_sum(2*n,b,(b+e)/2,i,j,carry+lazy[n]);
    int p2=get_sum(2*n+1,(b+e)/2+1,e,i,j,carry+lazy[n]);
    return p1+p2;
} */
int find_right(int l,int n)
{
    int p1=l-1,p2=n+1;
    int pre=query(l,l);
    while(p2-p1>1)
    {
        int mid=(p1+p2)/2;
        if(query(mid,mid)-pre==mid-l)
            p1=mid;
        else
            p2=mid;
    }
    return p1;

}
int find_left(int l,int r=1)
{
    int p1=r-1,p2=l+1;
    int pre=query(l,l);
    while(p2-p1>1)
    {
        int mid=(p1+p2)/2;
        if(query(mid,mid)-pre==mid-l)
            p2=mid;
        else
            p1=mid;
    }
    return p2;

}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,q;
    cin>>n>>q;
    vector<int>v(n+1),v1(n+1,1);
    for(int i=1;i<=n;i++)
        cin>>v[i];
    update(1,1,v1[1]);
    for(int i=2;i<=n;i++)
    {
        if(v[i]>=v[i-1])
            v1[i]=v1[i-1]+1;
        else
            v1[i]=1;
        update(i,i,v1[i]) ;
    }


    while(q--)
    {
        int t,l,r;
        cin>>t>>l>>r;

        if(t==1)
        {
            int p1=l,p2=l;
            if(l-1>0 and v[l-1]<=r)
            {
                p1=find_left(l-1);
                update(p1,l-1,-1*query(p1,p1),-1);
            }
            if(l+1<=n and v[l+1]>=r)
            {

                p2=find_right(l+1,n);
                update(l+1,p2,-1*query(l+1,l+1),-1);
            }
            else if(l+1<=n )
            {
                int pp=find_right(l+1,n);
                update(l+1,pp,-query(l+1,l+1),-1);
                update(l+1,pp);

            }

            update(l,l,-query(l,l),-1);
            update(p1,p2);
            v[l]=r;
        }
        else
        {
            int p1=find_right(l,r);
            int p2=find_left(r,l);
            int ans=(p1-l+1)*(p1-l+2)/2;
            if(p1<r)
            ans+=(r-p2+1)*(r-p2+2)/2;
            p1++;
            p2--;
            if(p1<=p2)
                ans+=query(p1,p2);
            cout<<ans<<endl;


        }

    }


}
