#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
struct ty {
  int l, r;
  long long ctl, ctr, s;
  bool f;
} t[N];
int in[N >> 2], locate[N >> 2];
inline long long get(long long x) { return x * (x + 1) / 2; }
inline void init_lzy(int i) {
  locate[t[i].l] = i;
  t[i].s = t[i].f = 1;
  t[i].ctl = t[i].ctr = 1;
}
inline ty push_up(ty &x, ty &y, ty &z) {
  if (in[x.r] <= in[y.l]) {
    long long len = x.ctr + y.ctl;
    z.s = x.s + y.s - get(x.ctr) - get(y.ctl) + get(len);
    z.ctl = x.ctl;
    z.ctr = y.ctr;
    if (x.f) z.ctl += y.ctl;
    if (y.f) z.ctr += x.ctr;
    if (x.f && y.f)
      z.f = 1;
    else
      z.f = 0;
  } else {
    z.s = x.s + y.s;
    z.ctl = x.ctl;
    z.ctr = y.ctr;
    z.f = 0;
  }
  z.l = x.l;
  z.r = y.r;
  return z;
}
void inline build(int i, int l, int r) {
  t[i].l = l;
  t[i].r = r;
  if (l == r) {
    init_lzy(i);
    return;
  }
  int m = (l + r) >> 1;
  build(i << 1, l, m);
  build(i << 1 | 1, m + 1, r);
  push_up(t[i << 1], t[i << 1 | 1], t[i]);
}
void change(int i) {
  while (1) {
    if (i == 1) break;
    if (i & 1)
      push_up(t[i - 1], t[i], t[i >> 1]);
    else
      push_up(t[i], t[i + 1], t[i >> 1]);
    i >>= 1;
  }
}
inline ty search_sum(int i, int l, int r) {
  if (l <= t[i].l && t[i].r <= r) {
    return t[i];
  }
  ty x, y, z;
  if (t[i << 1].r >= l && t[i << 1 | 1].l > r) z = search_sum(i << 1, l, r);
  if (t[i << 1 | 1].l <= r && t[i << 1].r < l)
    z = search_sum(i << 1 | 1, l, r);
  else if (t[i << 1].r >= l && t[i << 1 | 1].l <= r) {
    x = search_sum(i << 1, l, r);
    y = search_sum(i << 1 | 1, l, r);
    z = push_up(x, y, z);
  }
  return z;
}
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> in[i];
  build(1, 1, n);
  while (q--) {
    int ti, l, r;
    cin >> ti >> l >> r;
    if (ti == 1) {
      in[l] = r;
      change(locate[l]);
    } else {
      cout << search_sum(1, l, r).s << endl;
    }
  }
  return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

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].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
struct ty {
  int l, r;
  long long ctl, ctr, s;
  bool f;
} t[N];
int in[N >> 2], locate[N >> 2];
inline long long get(long long x) { return x * (x + 1) / 2; }
inline void init_lzy(int i) {
  locate[t[i].l] = i;
  t[i].s = t[i].f = 1;
  t[i].ctl = t[i].ctr = 1;
}
inline ty push_up(ty &x, ty &y, ty &z) {
  if (in[x.r] <= in[y.l]) {
    long long len = x.ctr + y.ctl;
    z.s = x.s + y.s - get(x.ctr) - get(y.ctl) + get(len);
    z.ctl = x.ctl;
    z.ctr = y.ctr;
    if (x.f) z.ctl += y.ctl;
    if (y.f) z.ctr += x.ctr;
    if (x.f && y.f)
      z.f = 1;
    else
      z.f = 0;
  } else {
    z.s = x.s + y.s;
    z.ctl = x.ctl;
    z.ctr = y.ctr;
    z.f = 0;
  }
  z.l = x.l;
  z.r = y.r;
  return z;
}
void inline build(int i, int l, int r) {
  t[i].l = l;
  t[i].r = r;
  if (l == r) {
    init_lzy(i);
    return;
  }
  int m = (l + r) >> 1;
  build(i << 1, l, m);
  build(i << 1 | 1, m + 1, r);
  push_up(t[i << 1], t[i << 1 | 1], t[i]);
}
void change(int i) {
  while (1) {
    if (i == 1) break;
    if (i & 1)
      push_up(t[i - 1], t[i], t[i >> 1]);
    else
      push_up(t[i], t[i + 1], t[i >> 1]);
    i >>= 1;
  }
}
inline ty search_sum(int i, int l, int r) {
  if (l <= t[i].l && t[i].r <= r) {
    return t[i];
  }
  ty x, y, z;
  if (t[i << 1].r >= l && t[i << 1 | 1].l > r) z = search_sum(i << 1, l, r);
  if (t[i << 1 | 1].l <= r && t[i << 1].r < l)
    z = search_sum(i << 1 | 1, l, r);
  else if (t[i << 1].r >= l && t[i << 1 | 1].l <= r) {
    x = search_sum(i << 1, l, r);
    y = search_sum(i << 1 | 1, l, r);
    z = push_up(x, y, z);
  }
  return z;
}
int main() {
  std::ios_base::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) cin >> in[i];
  build(1, 1, n);
  while (q--) {
    int ti, l, r;
    cin >> ti >> l >> r;
    if (ti == 1) {
      in[l] = r;
      change(locate[l]);
    } else {
      cout << search_sum(1, l, r).s << endl;
    }
  }
  return 0;
}

```