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].
// Problem: E. Non-Decreasing Dilemma
// Contest: Codeforces - Codeforces Round #742 (Div. 2)
// URL: https://codeforces.com/contest/1567/problem/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define uset unordered_set
#define umap unordered_map
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a));
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const int MM = 2e5+5;
struct node {
	int l, r, plen, slen, pnum, snum, sum;
};
int N, Q, arr[MM];
node seg[4 * MM];
void build(int l, int r, int num) {
	seg[num].l = l;
	seg[num].r = r;
	if (l == r) {
		seg[num].sum = 1;
		seg[num].plen = 1;
		seg[num].slen = 1;
		seg[num].pnum = arr[l];
		seg[num].snum = arr[l];
		return;
	}
	int mid = (l + r) / 2;
	// left
	build(l, mid, 2 * num);
	// right
	build(mid + 1, r, 2 * num + 1);
	// merge
	seg[num].sum = seg[2 * num].sum + seg[2 * num + 1].sum + (seg[2 * num].snum > seg[2 * num + 1].pnum ? 0 : (seg[2 * num].slen * seg[2 * num + 1].plen));
	// full length prefix non-decreasing able to merge
	if (seg[2 * num].plen == seg[2 * num].r - seg[2 * num].l + 1 && seg[2 * num].snum <= seg[2 * num + 1].pnum) {
		seg[num].plen = seg[2 * num].plen + seg[2 * num + 1].plen;
	} 
	// otherwise only left prefix
	else {
		seg[num].plen = seg[2 * num].plen;
	}
	// full length suffix non-decreasing able to merge
	if (seg[2 * num + 1].slen == seg[2 * num + 1].r - seg[2 * num + 1].l + 1 && seg[2 * num].snum <= seg[2 * num + 1].pnum) {
		seg[num].slen = seg[2 * num].slen + seg[2 * num + 1].slen;
	}
	// otherwise only right suffix
	else {
		seg[num].slen = seg[2 * num + 1].slen;
	}
	// set first and last numbers
	seg[num].snum = seg[2 * num + 1].snum;
	seg[num].pnum = seg[2 * num].pnum;
}
void update(int idx, int val, int num) {
	if (seg[num].l == idx && seg[num].r == idx) {
		seg[num].pnum = val;
		seg[num].snum = val;
		return;
	}
	int mid = (seg[num].l + seg[num].r) / 2;
	if (idx <= mid) update(idx, val, 2 * num);
	else update(idx, val, 2 * num + 1);
	// merge, same as build
	seg[num].sum = seg[2 * num].sum + seg[2 * num + 1].sum + (seg[2 * num].snum > seg[2 * num + 1].pnum ? 0 : (seg[2 * num].slen * seg[2 * num + 1].plen));
	// full length prefix non-decreasing able to merge
	if (seg[2 * num].plen == seg[2 * num].r - seg[2 * num].l + 1 && seg[2 * num].snum <= seg[2 * num + 1].pnum) {
		seg[num].plen = seg[2 * num].plen + seg[2 * num + 1].plen;
	} 
	// otherwise only left prefix
	else {
		seg[num].plen = seg[2 * num].plen;
	}
	// full length suffix non-decreasing able to merge
	if (seg[2 * num + 1].slen == seg[2 * num + 1].r - seg[2 * num + 1].l + 1 && seg[2 * num].snum <= seg[2 * num + 1].pnum) {
		seg[num].slen = seg[2 * num].slen + seg[2 * num + 1].slen;
	}
	// otherwise only right suffix
	else {
		seg[num].slen = seg[2 * num + 1].slen;
	}
	// set first and last numbers
	seg[num].snum = seg[2 * num + 1].snum;
	seg[num].pnum = seg[2 * num].pnum;
}
int query(int l, int r, int num) {
	if (l == seg[num].l && r == seg[num].r) {
		return seg[num].sum;
	}
	int mid = (seg[num].l + seg[num].r) / 2;
	if (r <= mid) return query(l, r, 2 * num);
	else if (l > mid) return query(l, r, 2 * num + 1);
	// we still have to perform the merge in this case
	else {
		return query(l, mid, 2 * num) + query(mid + 1, r, 2 * num + 1) + (seg[2 * num].snum > seg[2 * num + 1].pnum ? 0 : (seg[2 * num].slen * seg[2 * num + 1].plen));
	}
}
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> Q;
	for (int i = 1; i <= N; ++i) cin >> arr[i];
	build(1, N, 1);
	/*for (int i = 1; i <= 4 * N; ++i) {
		cout << "l: " << seg[i].l << "\n";
		cout << "r: " << seg[i].r << "\n";
		cout << "plen: " << seg[i].plen << "\n";
		cout << "slen: " << seg[i].slen << "\n";
		cout << "pnum: " << seg[i].pnum << "\n";
		cout << "snum: " << seg[i].snum << "\n";
		cout << "sum: " << seg[i].sum << "\n";
		cout << "\n";
	}*/
	for (int i = 1; i <= Q; ++i) {
		int key, a, b;
		cin >> key >> a >> b;
		if (key == 1) {
			update(a, b, 1);
		} else {
			cout << query(a, b, 1) << "\n";
		}
	}
}