#include <cstdio>
#include <algorithm>
const int MAX_N = 100000;
int arbint[5 + 2 * MAX_N];
int maxInt, a, b;
void update(int node, int st, int dr, int poz, int x) {
if (st == dr) {
arbint[node] = x;
return;
}
int med = (st + dr) / 2;
if (poz <= med) {
update(2 * node, st, med, poz, x);
} else {
update(2 * node + 1, med + 1, dr, poz, x);
}
arbint[node] = std::max(arbint[2 * node], arbint[2 * node + 1]);
}
void query(int node, int st, int dr) {
if (a <= st && dr <= b) {
maxInt = std::max(maxInt, arbint[node]);
return;
}
if (st == dr) {
return;
}
int med = (st + dr) / 2;
query(node * 2, st, med);
query(node * 2 + 1, med + 1, dr);
}
int main() {
freopen ("arbint.in", "r", stdin);
freopen ("arbint.out", "w", stdout);
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
int x;
scanf("%d", &x);
update(1, 1, n, i, x);
}
for (int i = 1; i <= m; ++i) {
int tip;
scanf("%d%d%d", &tip, &a, &b);
if (tip == 0) {
maxInt = 0;
query(1, 1, n);
printf("%d\n", maxInt);
} else {
update(1, 1, n, a, b);
}
}
return 0;
}