#include <bits/stdc++.h>
using namespace std;
struct dsu {
  vector<int> root;
  dsu(int n) : root(n) {
    for (int i = 0; i < n; ++i) {
      root[i] = i;
    }
  }
  int find_set(int v) {
    if (v == root[v]) return v;
    return root[v] = find_set(root[v]);
  }
  bool check_roots(int left, int right) {
    left = find_set(left);
    right = find_set(right);
    return left != right;
  }
  void union_sets(int left, int right) {
    left = find_set(left);
    right = find_set(right);
    if (left != right) {
      if (left > right) swap(left, right);
      root[right] = left;
    }
  }
};
struct node {
  int64_t ans;
  int64_t len;
  int64_t f, l;
  int64_t ll, rl;
  bool operator==(const node &oth) const {
    return ans == oth.ans && len == oth.len && f == oth.f && l == oth.l &&
           ll == oth.ll && rl == oth.rl;
  }
} fict = {-1, -1, -1, -1, -1, -1};
int n;
struct SegmentTree {
  vector<int> nums;
  vector<node> tree;
  SegmentTree(const vector<int> &vc) : nums(vc) {
    tree.resize(4 * nums.size());
    function<void(int, int, int)> build = [&](int v, int tl, int tr) {
      if (tl == tr) {
        tree[v] = {1, 1, nums[tl], nums[tl], 1, 1};
      } else {
        int tm = (tl + tr) / 2;
        build(2 * v, tl, tm);
        build(2 * v + 1, tm + 1, tr);
        tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
      }
    };
    build(1, 0, (int)nums.size() - 1);
  }
  static node merge(node left, node right) {
    if (left == fict) return right;
    if (right == fict) return left;
    int64_t len = left.len + right.len;
    int64_t ans = left.ans + right.ans;
    if (left.l <= right.f) {
      ans += (left.rl * right.ll);
    }
    int64_t inc_pref = left.ll;
    if (left.ll == left.len && left.l <= right.f) {
      inc_pref += right.ll;
    }
    int64_t inc_suf = right.rl;
    if (right.rl == right.len and left.l <= right.f) {
      inc_suf += left.rl;
    }
    int64_t first = left.f, last = right.l;
    return {ans, len, first, last, inc_pref, inc_suf};
  }
  void update(int pos, int new_val, int v = 1, int tl = 0, int tr = n - 1) {
    if (tl == tr) {
      tree[v].f = tree[v].l = nums[pos] = new_val;
    } else {
      int tm = (tl + tr) / 2;
      if (pos <= tm) {
        update(pos, new_val, 2 * v, tl, tm);
      } else {
        update(pos, new_val, 2 * v + 1, tm + 1, tr);
      }
      tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
    }
  }
  node get_ans(int l, int r, int v = 1, int tl = 0, int tr = n - 1) {
    if (tr < l || r < tl) {
      return fict;
    }
    if (l <= tl && tr <= r) {
      return tree[v];
    }
    int tm = (tl + tr) / 2;
    node left = get_ans(l, r, v * 2, tl, tm);
    node right = get_ans(l, r, v * 2 + 1, tm + 1, tr);
    return merge(left, right);
  }
  void print_tree(ostream &os = cout) const {
    os << "tree:\n";
    for (int i = 1; i < tree.size(); ++i) {
      os << i << ": " << tree[i].ans << endl;
    }
  }
  void print_nums(ostream &os = cout) const {
    os << "nums: ";
    for (int e : nums) {
      os << e << " ";
    }
    os << endl;
  }
};
void solve() {
  int q;
  cin >> n >> q;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  SegmentTree tree(v);
  while (q--) {
    int p;
    cin >> p;
    if (p == 1) {
      int x, y;
      cin >> x >> y;
      --x;
      tree.update(x, y);
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      cout << tree.get_ans(l, r).ans << "\n";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

### Prompt

Please create a solution in CPP 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;
struct dsu {
  vector<int> root;
  dsu(int n) : root(n) {
    for (int i = 0; i < n; ++i) {
      root[i] = i;
    }
  }
  int find_set(int v) {
    if (v == root[v]) return v;
    return root[v] = find_set(root[v]);
  }
  bool check_roots(int left, int right) {
    left = find_set(left);
    right = find_set(right);
    return left != right;
  }
  void union_sets(int left, int right) {
    left = find_set(left);
    right = find_set(right);
    if (left != right) {
      if (left > right) swap(left, right);
      root[right] = left;
    }
  }
};
struct node {
  int64_t ans;
  int64_t len;
  int64_t f, l;
  int64_t ll, rl;
  bool operator==(const node &oth) const {
    return ans == oth.ans && len == oth.len && f == oth.f && l == oth.l &&
           ll == oth.ll && rl == oth.rl;
  }
} fict = {-1, -1, -1, -1, -1, -1};
int n;
struct SegmentTree {
  vector<int> nums;
  vector<node> tree;
  SegmentTree(const vector<int> &vc) : nums(vc) {
    tree.resize(4 * nums.size());
    function<void(int, int, int)> build = [&](int v, int tl, int tr) {
      if (tl == tr) {
        tree[v] = {1, 1, nums[tl], nums[tl], 1, 1};
      } else {
        int tm = (tl + tr) / 2;
        build(2 * v, tl, tm);
        build(2 * v + 1, tm + 1, tr);
        tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
      }
    };
    build(1, 0, (int)nums.size() - 1);
  }
  static node merge(node left, node right) {
    if (left == fict) return right;
    if (right == fict) return left;
    int64_t len = left.len + right.len;
    int64_t ans = left.ans + right.ans;
    if (left.l <= right.f) {
      ans += (left.rl * right.ll);
    }
    int64_t inc_pref = left.ll;
    if (left.ll == left.len && left.l <= right.f) {
      inc_pref += right.ll;
    }
    int64_t inc_suf = right.rl;
    if (right.rl == right.len and left.l <= right.f) {
      inc_suf += left.rl;
    }
    int64_t first = left.f, last = right.l;
    return {ans, len, first, last, inc_pref, inc_suf};
  }
  void update(int pos, int new_val, int v = 1, int tl = 0, int tr = n - 1) {
    if (tl == tr) {
      tree[v].f = tree[v].l = nums[pos] = new_val;
    } else {
      int tm = (tl + tr) / 2;
      if (pos <= tm) {
        update(pos, new_val, 2 * v, tl, tm);
      } else {
        update(pos, new_val, 2 * v + 1, tm + 1, tr);
      }
      tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
    }
  }
  node get_ans(int l, int r, int v = 1, int tl = 0, int tr = n - 1) {
    if (tr < l || r < tl) {
      return fict;
    }
    if (l <= tl && tr <= r) {
      return tree[v];
    }
    int tm = (tl + tr) / 2;
    node left = get_ans(l, r, v * 2, tl, tm);
    node right = get_ans(l, r, v * 2 + 1, tm + 1, tr);
    return merge(left, right);
  }
  void print_tree(ostream &os = cout) const {
    os << "tree:\n";
    for (int i = 1; i < tree.size(); ++i) {
      os << i << ": " << tree[i].ans << endl;
    }
  }
  void print_nums(ostream &os = cout) const {
    os << "nums: ";
    for (int e : nums) {
      os << e << " ";
    }
    os << endl;
  }
};
void solve() {
  int q;
  cin >> n >> q;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  SegmentTree tree(v);
  while (q--) {
    int p;
    cin >> p;
    if (p == 1) {
      int x, y;
      cin >> x >> y;
      --x;
      tree.update(x, y);
    } else {
      int l, r;
      cin >> l >> r;
      --l, --r;
      cout << tree.get_ans(l, r).ans << "\n";
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```