#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int T[4*MAXN], n, a[MAXN], maxx;
void init(int node, int b, int e){
if(b==e){
T[node]=a[b];
return;
}
int m=(b+e)/2;
init(node*2, b, m);
init(node*2+1, m+1, e);
T[node]=max(T[node*2], T[node*2+1]);
}
void query(int node, int b, int e, int l, int r){
if(b>=l && e<=r){
maxx=max(maxx, T[node]);
return;
}
int m=(b+e)/2;
if(l<=m) query(node*2, b, m, l, r);
if(r>m) query(node*2+1, m+1, e, l, r);
}
void update(int node, int b, int e, int pos, int val){
if(b==e){
T[node]=val;
return;
}
int m=(b+e)/2;
if(pos<=m) update(node*2, b, m, pos, val);
else update(node*2+1, m+1, e, pos, val);
T[node]=max(T[node*2], T[node*2+1]);
}
int main ()
{
int i, m, x, y; fin>>n>>m;
for(i=1; i<=n; ++i)
fin>>a[i];
init(1, 1, n);
while(m--){
bool type; fin>>type>>x>>y; // x pos
if(type==0){
maxx=0;
query(1, 1, n, x, y);
fout<<maxx<<'\n';
} else update(1, 1, n, x, y);
}
return 0;
}