var t:array[1..1 shl 18] of longint;
m,maxim,p,v,a,b:longint;
fin,fout:text;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;
procedure update(nod,l,r:longint);
begin
if l<r then
if p<=(l+r) shr 1 then
update(nod shl 1,l,(l+r) shr 1)
else
update((nod shl 1)+1,((l+r) shr 1)+1,r);
if l=r then
t[nod]:=v else t[nod]:=max(t[nod shl 1],t[(nod shl 1)+1]);
end;
procedure query(nod,l,r:longint);
begin
if (a<=l) and (r<=b) then
begin
if maxim<t[nod] then maxim:=t[nod];
exit
end
else
begin
if a<=(l+r) shr 1 then query(nod shl 1,l,(l+r) shr 1);
if (l+r) shr 1<b then query((nod shl 1)+1,((l+r) shr 1)+1,r);
end;
end;
procedure citire;
var n,m,i:longint;
x,y,z:longint;
begin
assign(fin,'arbint.in');reset(fin);
readln(fin,n,m);
for i:=1 to n do
begin
read(fin,x);
p:=i;v:=x;
update(1,1,n);
end;
assign(fout,'arbint.out');rewrite(fout);
for i:=1 to m do
begin
read(fin,x,y,z);
if x=0 then
begin
a:=y;
b:=z;maxim:=0;
query(1,1,n);
write(maxim,#10);
end
else
begin
p:=y;
v:=z;
update(1,1,n);
end;
end;
close(fin);close(fout);
end;
begin
citire;
end.