#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long a = 0;
  long long d = 1;
  char c;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-') d = -1;
  a = a * 10 + c - 48;
  while (c = getchar(), c >= '0' && c <= '9') a = a * 10 + c - 48;
  a *= d;
  return a;
}
long long a[1005000];
long long val[1005000];
long long n, q;
long long ed;
void init() {
  for (long long i = 1; i <= n; i++) val[i] = val[i - 1] + i;
}
struct node {
  long long l, r;
  long long pre, sul;
  long long mid;
  bool all;
} c[1005000];
vector<long long> qq;
bool cmp(long long a, long long b) {
  if (c[a].l == c[b].l) return c[a].r < c[b].r;
  return c[a].l < c[b].l;
}
inline long long ls(long long x) { return x << 1; }
inline long long rs(long long x) { return x << 1 | 1; }
inline void pushup(long long p, long long lss, long long rss) {
  if (c[lss].all && c[rss].all) {
    c[p].mid = 0;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].all = true;
      c[p].pre = c[lss].pre + c[rss].pre;
      c[p].sul = c[p].pre;
    } else {
      c[p].all = false;
      c[p].pre = c[lss].pre;
      c[p].sul = c[rss].pre;
    }
  } else if (c[lss].all && !c[rss].all) {
    c[p].all = false;
    c[p].sul = c[rss].sul;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].pre = c[lss].pre + c[rss].pre;
      c[p].mid = c[rss].mid;
    } else {
      c[p].pre = c[lss].pre;
      c[p].mid = c[rss].mid + val[c[rss].pre];
    }
  } else if (!c[lss].all && c[rss].all) {
    c[p].all = false;
    c[p].pre = c[lss].pre;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].sul = c[lss].sul + c[rss].pre;
      c[p].mid = c[lss].mid;
    } else {
      c[p].sul = c[rss].pre;
      c[p].mid = c[lss].mid + val[c[lss].sul];
    }
  } else {
    c[p].all = false;
    c[p].pre = c[lss].pre;
    c[p].sul = c[rss].sul;
    if (a[c[lss].r] <= a[c[rss].l])
      c[p].mid = c[lss].mid + c[rss].mid + val[c[lss].sul + c[rss].pre];
    else
      c[p].mid = c[lss].mid + c[rss].mid + val[c[lss].sul] + val[c[rss].pre];
  }
}
void build(long long p, long long l, long long r) {
  c[p].l = l;
  c[p].r = r;
  if (l == r) {
    c[p].all = true;
    c[p].pre = 1;
    c[p].sul = 1;
    c[p].mid = 0;
    return;
  }
  long long mid = (l + r) >> 1;
  build(ls(p), l, mid);
  build(rs(p), mid + 1, r);
  pushup(p, ls(p), rs(p));
}
void update(long long p, long long x, long long z) {
  if (c[p].l == c[p].r) {
    a[c[p].l] = z;
    return;
  }
  long long mid = (c[p].l + c[p].r) >> 1;
  if (x <= mid)
    update(ls(p), x, z);
  else
    update(rs(p), x, z);
  pushup(p, ls(p), rs(p));
}
void query(long long p, long long x, long long y) {
  if (x <= c[p].l && y >= c[p].r) {
    qq.push_back(p);
    return;
  }
  long long mid = (c[p].l + c[p].r) >> 1;
  if (x <= mid) query(ls(p), x, y);
  if (y > mid) query(rs(p), x, y);
}
signed main() {
  n = read();
  q = read();
  init();
  for (long long i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  ed = (n << 2) + 10;
  while (q--) {
    long long op = read();
    long long x = read();
    long long y = read();
    if (op == 1)
      update(1, x, y);
    else {
      qq.clear();
      query(1, x, y);
      sort(qq.begin(), qq.end(), cmp);
      c[ed] = c[qq[0]];
      for (long long i = 1; i < qq.size(); i++) {
        c[ed + 1].l = c[ed].l;
        c[ed + 1].r = c[qq[i]].r;
        pushup(ed + 1, ed, qq[i]);
        c[ed] = c[ed + 1];
      }
      long long ans = 0;
      if (c[ed].all)
        ans = val[c[ed].pre];
      else
        ans = val[c[ed].pre] + val[c[ed].sul] + c[ed].mid;
      printf("%lld\n", ans);
    }
  }
  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;
long long read() {
  long long a = 0;
  long long d = 1;
  char c;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-') d = -1;
  a = a * 10 + c - 48;
  while (c = getchar(), c >= '0' && c <= '9') a = a * 10 + c - 48;
  a *= d;
  return a;
}
long long a[1005000];
long long val[1005000];
long long n, q;
long long ed;
void init() {
  for (long long i = 1; i <= n; i++) val[i] = val[i - 1] + i;
}
struct node {
  long long l, r;
  long long pre, sul;
  long long mid;
  bool all;
} c[1005000];
vector<long long> qq;
bool cmp(long long a, long long b) {
  if (c[a].l == c[b].l) return c[a].r < c[b].r;
  return c[a].l < c[b].l;
}
inline long long ls(long long x) { return x << 1; }
inline long long rs(long long x) { return x << 1 | 1; }
inline void pushup(long long p, long long lss, long long rss) {
  if (c[lss].all && c[rss].all) {
    c[p].mid = 0;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].all = true;
      c[p].pre = c[lss].pre + c[rss].pre;
      c[p].sul = c[p].pre;
    } else {
      c[p].all = false;
      c[p].pre = c[lss].pre;
      c[p].sul = c[rss].pre;
    }
  } else if (c[lss].all && !c[rss].all) {
    c[p].all = false;
    c[p].sul = c[rss].sul;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].pre = c[lss].pre + c[rss].pre;
      c[p].mid = c[rss].mid;
    } else {
      c[p].pre = c[lss].pre;
      c[p].mid = c[rss].mid + val[c[rss].pre];
    }
  } else if (!c[lss].all && c[rss].all) {
    c[p].all = false;
    c[p].pre = c[lss].pre;
    if (a[c[lss].r] <= a[c[rss].l]) {
      c[p].sul = c[lss].sul + c[rss].pre;
      c[p].mid = c[lss].mid;
    } else {
      c[p].sul = c[rss].pre;
      c[p].mid = c[lss].mid + val[c[lss].sul];
    }
  } else {
    c[p].all = false;
    c[p].pre = c[lss].pre;
    c[p].sul = c[rss].sul;
    if (a[c[lss].r] <= a[c[rss].l])
      c[p].mid = c[lss].mid + c[rss].mid + val[c[lss].sul + c[rss].pre];
    else
      c[p].mid = c[lss].mid + c[rss].mid + val[c[lss].sul] + val[c[rss].pre];
  }
}
void build(long long p, long long l, long long r) {
  c[p].l = l;
  c[p].r = r;
  if (l == r) {
    c[p].all = true;
    c[p].pre = 1;
    c[p].sul = 1;
    c[p].mid = 0;
    return;
  }
  long long mid = (l + r) >> 1;
  build(ls(p), l, mid);
  build(rs(p), mid + 1, r);
  pushup(p, ls(p), rs(p));
}
void update(long long p, long long x, long long z) {
  if (c[p].l == c[p].r) {
    a[c[p].l] = z;
    return;
  }
  long long mid = (c[p].l + c[p].r) >> 1;
  if (x <= mid)
    update(ls(p), x, z);
  else
    update(rs(p), x, z);
  pushup(p, ls(p), rs(p));
}
void query(long long p, long long x, long long y) {
  if (x <= c[p].l && y >= c[p].r) {
    qq.push_back(p);
    return;
  }
  long long mid = (c[p].l + c[p].r) >> 1;
  if (x <= mid) query(ls(p), x, y);
  if (y > mid) query(rs(p), x, y);
}
signed main() {
  n = read();
  q = read();
  init();
  for (long long i = 1; i <= n; i++) a[i] = read();
  build(1, 1, n);
  ed = (n << 2) + 10;
  while (q--) {
    long long op = read();
    long long x = read();
    long long y = read();
    if (op == 1)
      update(1, x, y);
    else {
      qq.clear();
      query(1, x, y);
      sort(qq.begin(), qq.end(), cmp);
      c[ed] = c[qq[0]];
      for (long long i = 1; i < qq.size(); i++) {
        c[ed + 1].l = c[ed].l;
        c[ed + 1].r = c[qq[i]].r;
        pushup(ed + 1, ed, qq[i]);
        c[ed] = c[ed + 1];
      }
      long long ans = 0;
      if (c[ed].all)
        ans = val[c[ed].pre];
      else
        ans = val[c[ed].pre] + val[c[ed].sul] + c[ed].mid;
      printf("%lld\n", ans);
    }
  }
  return 0;
}

```