#include <bits/stdc++.h>
using std::max;
using std::min;
const int maxn = 2e5 + 10;
int n, m, a[maxn];
struct node {
  int len[2], s, e, size;
  long long sum;
};
class Segtree {
 private:
  int bound;
  node data[maxn << 2];
  inline node unite(const node &x, const node &y) {
    node res;
    res.s = x.s, res.e = y.e;
    res.sum = x.sum + y.sum;
    res.size = x.size + y.size;
    if (x.e <= y.s) {
      if (x.len[0] == x.size)
        res.len[0] = x.len[0] + y.len[0];
      else
        res.len[0] = x.len[0];
      if (y.len[1] == y.size)
        res.len[1] = x.len[1] + y.len[1];
      else
        res.len[1] = y.len[1];
      res.sum += 1ll * x.len[1] * y.len[0];
    } else {
      res.len[0] = x.len[0];
      res.len[1] = y.len[1];
    }
    return res;
  }
  inline void pushup(int u) { data[u] = unite(data[u << 1], data[u << 1 | 1]); }
  void build(int s, int e, int u) {
    if (s == e) {
      data[u].s = a[s], data[u].e = a[e];
      data[u].len[0] = 1, data[u].len[1] = 1;
      data[u].size = 1, data[u].sum = 1;
      return;
    }
    int mid = (s + e) >> 1;
    build(s, mid, u << 1), build(mid + 1, e, u << 1 | 1);
    pushup(u);
  }
  void modify(int s, int e, int u, int pos, int key) {
    if (s == e) {
      a[pos] = key;
      data[u].s = key, data[u].e = key;
      return;
    }
    int mid = (s + e) >> 1;
    if (pos <= mid)
      modify(s, mid, u << 1, pos, key);
    else
      modify(mid + 1, e, u << 1 | 1, pos, key);
    pushup(u);
  }
  node query(int s, int e, int u, int ql, int qr) {
    if (ql <= s && e <= qr) {
      return data[u];
    }
    int mid = (s + e) >> 1;
    if (ql <= mid && qr > mid) {
      return unite(query(s, mid, u << 1, ql, qr),
                   query(mid + 1, e, u << 1 | 1, ql, qr));
    } else if (ql <= mid)
      return query(s, mid, u << 1, ql, qr);
    return query(mid + 1, e, u << 1 | 1, ql, qr);
  }

 public:
  inline void build(int n) {
    bound = n;
    build(1, bound, 1);
  }
  inline void modify(int pos, int key) { modify(1, bound, 1, pos, key); }
  inline long long query(int ql, int qr) {
    return query(1, bound, 1, ql, qr).sum;
  }
} tree;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  tree.build(n);
  int opt, x, y;
  while (m--) {
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1)
      tree.modify(x, y);
    else
      printf("%lld\n", tree.query(x, y));
  }
  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 std::max;
using std::min;
const int maxn = 2e5 + 10;
int n, m, a[maxn];
struct node {
  int len[2], s, e, size;
  long long sum;
};
class Segtree {
 private:
  int bound;
  node data[maxn << 2];
  inline node unite(const node &x, const node &y) {
    node res;
    res.s = x.s, res.e = y.e;
    res.sum = x.sum + y.sum;
    res.size = x.size + y.size;
    if (x.e <= y.s) {
      if (x.len[0] == x.size)
        res.len[0] = x.len[0] + y.len[0];
      else
        res.len[0] = x.len[0];
      if (y.len[1] == y.size)
        res.len[1] = x.len[1] + y.len[1];
      else
        res.len[1] = y.len[1];
      res.sum += 1ll * x.len[1] * y.len[0];
    } else {
      res.len[0] = x.len[0];
      res.len[1] = y.len[1];
    }
    return res;
  }
  inline void pushup(int u) { data[u] = unite(data[u << 1], data[u << 1 | 1]); }
  void build(int s, int e, int u) {
    if (s == e) {
      data[u].s = a[s], data[u].e = a[e];
      data[u].len[0] = 1, data[u].len[1] = 1;
      data[u].size = 1, data[u].sum = 1;
      return;
    }
    int mid = (s + e) >> 1;
    build(s, mid, u << 1), build(mid + 1, e, u << 1 | 1);
    pushup(u);
  }
  void modify(int s, int e, int u, int pos, int key) {
    if (s == e) {
      a[pos] = key;
      data[u].s = key, data[u].e = key;
      return;
    }
    int mid = (s + e) >> 1;
    if (pos <= mid)
      modify(s, mid, u << 1, pos, key);
    else
      modify(mid + 1, e, u << 1 | 1, pos, key);
    pushup(u);
  }
  node query(int s, int e, int u, int ql, int qr) {
    if (ql <= s && e <= qr) {
      return data[u];
    }
    int mid = (s + e) >> 1;
    if (ql <= mid && qr > mid) {
      return unite(query(s, mid, u << 1, ql, qr),
                   query(mid + 1, e, u << 1 | 1, ql, qr));
    } else if (ql <= mid)
      return query(s, mid, u << 1, ql, qr);
    return query(mid + 1, e, u << 1 | 1, ql, qr);
  }

 public:
  inline void build(int n) {
    bound = n;
    build(1, bound, 1);
  }
  inline void modify(int pos, int key) { modify(1, bound, 1, pos, key); }
  inline long long query(int ql, int qr) {
    return query(1, bound, 1, ql, qr).sum;
  }
} tree;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  tree.build(n);
  int opt, x, y;
  while (m--) {
    scanf("%d%d%d", &opt, &x, &y);
    if (opt == 1)
      tree.modify(x, y);
    else
      printf("%lld\n", tree.query(x, y));
  }
  return 0;
}

```