#include <iostream>
#include <fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n,i,j,st,dr,p,v[100001],aint[265000],poz,m,x,a,b,lefti,righti;
inline 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]=max(aint[2*p],aint[2*p+1]);
}
}
inline void update()
{
int p=1, st=1, dr=n, m;
while(st<dr)
{
m=(st+dr)/2;
if(poz>m) st=m+1, p=2*p+1;
else dr=m, p=2*p;
}
aint[p]=v[st];
p/=2;
while(p)
{
aint[p]=max(aint[2*p],aint[2*p+1]);
p/=2;
}
}
inline int query()
{
int p=1, st=1, dr=n, m=(n+1)/2, fp, fst, fdr, sol=0;
while(lefti>m || righti<=m)
{
if(lefti>m) st=m+1, p=2*p+1;
if(righti<=m) dr=m, p=2*p;
m=(st+dr)/2;
}
fst=st;
fdr=dr;
fp=p;
dr=m;
p=2*p;
while(st<lefti)
{
m=(st+dr)/2;
if(lefti>m) st=m+1, p=2*p+1;
else
{
sol=max(sol, aint[2*p+1]);
dr=m;
p=2*p;
}
}
sol=max(sol, aint[p]);
st=fst;
dr=fdr;
p=fp;
st=m+1;
p=2*p+1;
while(dr>righti)
{
m=(st+dr)/2;
if(righti<=m) dr=m, p=2*p;
else
{
sol=max(sol, aint[2*p]);
st=m+1;
p=2*p+1;
}
}
sol=max(sol, aint[p]);
return sol;
}
int main()
{
f>>n>>m;
for(i=1;i<=n;i++) f>>v[i];
dfs(1,1,n);
for(i=1;i<=m;i++)
{
f>>x>>a>>b;
if(!x)
{
poz=a;
v[poz]=b;
update();
}
else
{
lefti=a;
righti=b;
int sol=query();
g<<sol<<'\n';
}
}
return 0;
}