var a:array[1..400100] of longint;
f,g:text;
maxim,i,n,m,q,w,x,poz:longint;
function max(x,y:longint):longint; begin if x<y then max:=y else max:=x; end;
procedure update(nod,st,dr:longint);
var mij:longint;
begin
if (st=dr) then
a[nod]:=x
else begin
mij:=(st+dr) shr 1;
if (poz<=mij) then update(nod shl 1,st,mij)
else update(nod shl 1+1,mij+1,dr);
a[nod]:=max(a[nod shl 1],a[nod shl 1+1]);
end;
end;
procedure query(nod,st,dr:longint);
var mij:longint;
begin
if (q<=st) and (dr<=w) then
maxim:=max(maxim,a[nod])
else begin
mij:=(st+dr) shr 1;
if (q<=mij) then
query(nod shl 1,st,mij);
if (mij<w) then
query(nod shl 1+1,mij+1,dr);
end;
end;
begin
assign(f,'arbint.in'); reset(f);
assign(g,'arbint.out'); rewrite(g);
read(f,n,m);
for i:=1 to n do begin
read(f,x);
poz:=i;
update(1,1,n);
end;
for i:=1 to m do begin
read(f,x,q,w);
if x=0 then begin
maxim:=-maxlongint;
query(1,1,n);
writeln(g,maxim);
end
else begin
poz:=q; x:=w;
update(1,1,n);
end;
end;
close(f); close(g);
end.