#include <cstdio>
#include <cctype>
#define BUF_SIZE 1<<17
#define MAXN 100000
#define MAXP 265000
int v[MAXN+1], aint[MAXP];
int n, left, right, poz, ans;
int pos=BUF_SIZE, pos2;
char buf[BUF_SIZE], buf2[BUF_SIZE];
FILE *fin, *fout;
inline char nextch(){
if(pos==BUF_SIZE) fread(buf, BUF_SIZE, 1, fin), pos=0;
return buf[pos++];
}
inline int read(){
int x=0;
char ch=nextch();
while(!isdigit(ch)) ch=nextch();
while(isdigit(ch)){
x=10*x+ch-'0';
ch=nextch();
}
return x;
}
inline void putch(char ch){
buf2[pos2++]=ch;
if(pos2==BUF_SIZE) fwrite(buf2, BUF_SIZE, 1, fout), pos2=0;
}
inline void baga(int x){
char s[10];
int k=0;
do{
s[k++]=x%10+'0';
x/=10;
}while(x);
while(k>0){
k--;
putch(s[k]);
}
}
inline int max2(int a, int b){
if(a>b) return a;
else return b;
}
void dfs(int p, int st, int dr){
if(st==dr) aint[p]=v[st];
else{
int m=(st+dr)/2;
dfs(2*p, st, m);
dfs(2*p+1, m+1, dr);
aint[p]=max2(aint[2*p], aint[2*p+1]);
}
}
void update(int p, int st, int dr){
if(st==dr) aint[p]=v[st];
else{
int m=(st+dr)/2;
if(poz<=m) update(2*p, st, m);
else update(2*p+1, m+1, dr);
aint[p]=max2(aint[2*p], aint[2*p+1]);
}
}
void query(int p, int st, int dr){
if((left<=st)&&(dr<=right)) ans=max2(ans, aint[p]);
else{
int m=(st+dr)/2;
if(left<=m) query(2*p, st, m);
if(m+1<=right) query(2*p+1, m+1, dr);
}
}
int main(){
int m, a, b, c;
fin=fopen("arbint.in", "r");
fout=fopen("arbint.out", "w");
n=read();
m=read();
for(int i=1; i<=n; i++)
v[i]=read();
dfs(1, 1, n);
for(int i=1; i<=m; i++){
a=read();
b=read();
c=read();
if(a==0){
left=b;
right=c;
ans=0;
query(1, 1, n);
baga(ans);
putch('\n');
}else{
poz=b;
v[poz]=c;
update(1, 1, n);
}
}
if(pos2>0) fwrite(buf2, pos2, 1, fout);
fclose(fin);
fclose(fout);
return 0;
}