#include <cstdio>
#define filein "arbint.in"
#define fileout "arbint.out"
#define MAX(a,b) (a>b)?(a):(b)
using namespace std;
int aint[500001];
int N,K;
int Answer;
void Update(int nod, int st, int dr, int poz, int val);
void Query(int nod, int st, int dr, int x, int y);
int main()
{
FILE *in,*out;
in=fopen(filein,"r");
out=fopen(fileout,"w");
fscanf(in,"%d%d",&N,&K);
register int i;
int x,y;
int todo;
for (i=1; i<=N; i++)
{
fscanf(in,"%d",&x);
Update(1,1,N,i,x);
}
for (i=1; i<=K; i++)
{
fscanf(in,"%d%d%d",&todo,&x,&y);
if (todo==0)
{
Answer=0;
Query(1,1,N,x,y);
fprintf(out,"%d\n",Answer);
}
else if (todo==1)
Update(1,1,N,x,y);
}
fclose(in);
fclose(out);
return 0;
}
void Update(int nod, int st, int dr, int poz, int val)
{
int med;
if (st==dr)
{
aint[nod]=val;
return;
}
med=(st+dr)>>1;
if (poz<=med) Update(2*nod,st,med,poz,val);
else Update(2*nod+1,med+1,dr,poz,val);
aint[nod]=MAX(aint[2*nod],aint[2*nod+1]);
}
void Query(int nod, int st, int dr, int x, int y)
{
int med;
if (x<=st && y>=dr)
{
Answer=MAX(Answer,aint[nod]);
return;
}
med=(st+dr)>>1;
if (x<=med) Query(2*nod,st,med,x,y);
if (y>med) Query(2*nod+1,med+1,dr,x,y);
}