var v:array[1..400000] of longint;
n,m,i,c,d,e:longint;
f,g:text;
function max(x,y:longint):longint;
begin
max:=(x+y+abs(x-y)) shr 1;
end;
function int(nod,a,b:longint):longint;
var mid,max1,max2,db:longint;
begin
if (d<=a) and (b<=e) then
int:=v[nod]
else
begin
db:=nod shl 1;
mid:=a+(b-a) shr 1;
max1:=0;
max2:=0;
if d<=mid then
max1:=int(db,a,mid);
if e>mid then
max2:=int(db+1,mid+1,b);
int:=max(max1,max2);
end;
end;
procedure update(nod,a,b:longint);
var mid,db:longint;
begin
if a=b then
v[nod]:=e
else
begin
mid:=a+(b-a) shr 1;
db:=nod shl 1;
if d<=mid then
update(db,a,mid)
else
update(db+1,mid+1,b);
v[nod]:=max(v[db],v[db+1]);
end;
end;
begin
assign(f,'arbint.in');
assign(g,'arbint.out');
reset(f);rewrite(g);
readln(f,n,m);
for d:=1 to n do
begin
read(f,e);
update(1,1,n);
end;
for i:=1 to m do
begin
readln(f,c,d,e);
if c=0 then
writeln(g,int(1,1,n))
else
update(1,1,n);
end;
close(f);close(g);
end.