#include <fstream>
#include <algorithm>
#define nmax 100004
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m, x, op, a, b, tree[4*nmax];
void update(int node, int low, int hi, int pos, int val) {
if(low==hi) {
tree[node]=val;
return;
}
int mid=(low+hi)/2, snode=2*node;
if(pos<=mid)
update(snode, low, mid, pos, val);
else
update(snode+1, mid+1, hi, pos, val);
tree[node]=max(tree[snode], tree[snode+1]);
}
int query(int node, int low, int hi, int a, int b) {
if(b<low || a>hi)
return 0;
if(a<=low && b>=hi)
return tree[node];
int mid=(low+hi)/2, snode=2*node;
return max(query(snode, low, mid, a, b), query(snode+1, mid+1, hi, a, b));
}
int main() {
f>>n>>m;
for(int i=1;i<=n;i++) {
f>>x;
update(1, 1, n, i, x);
}
for(int i=1;i<=m;i++) {
f>>op>>a>>b;
if(op==0)
g<<query(1, 1, n, a, b)<<'\n';
else
update(1, 1, n, a, b);
}
f.close();
g.close();
return 0;
}