#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int n, m, arbint[400005], a, b, t, res;
void update(int nod, int st, int dr, int pos, int val) {
if(st == dr) {
arbint[nod] = val;
return;
}
int m = (st+dr)/2;
if(pos <= m)
update(2*nod, st, m, pos, val);
else
update(2*nod+1, m+1, dr, pos, val);
arbint[nod] = max(arbint[2*nod], arbint[2*nod+1]);
}
void query(int nod, int st, int dr) {
if(a <= st && dr <= b) {
res = max(res, arbint[nod]);
return;
}
int m = (st+dr)/2;
if(a <= m)
query(2*nod, st, m);
if(m < b)
query(2*nod+1, m+1, dr);
}
void citire() {
fin >> n >> m;
int x;
for(int i = 1; i <= n; i++) {
fin >> x;
update(1, 1, n, i, x);
}
}
int main() {
citire();
while(m--) {
fin >> t >> a >> b;
if(t == 0) {
res = 0;
query(1, 1, n);
fout << res << '\n';
} else update(1, 1, n, a, b);
}
}