#include <fstream>
#define TSize 131073
using namespace std;
ifstream in;
ofstream out;
int T[TSize];
inline int max(int a,int b)
{
if(a<b) return b;
return a;
}
inline void update(int nod,int L,int R,int pos,int val)
{
if(L==pos&&pos==R)
{
T[nod]=val;
return;
}
int M=(L+R)>>1;
if(pos<=M) update(nod<<1,L,M,pos,val);
else update((nod<<1)+1,M+1,R,pos,val);
T[nod]=max(T[nod<<1],T[(nod<<1)+1]);
}
inline int query(int nod,int L,int R,int a,int b)
{
if(a<=L&&R<=b) return T[nod];
int M=(L+R)>>1;
int x1=0,x2=0;
if(a<=M) x1=query(nod<<1,L,M,a,b);
if(b>M) x2=query((nod<<1)+1,M+1,R,a,b);
return max(x1,x2);
}
int main()
{
int M,N,x,a,b;
in.open("arbint.in");
in>>N>>M;
for(int i=1;i<=N;++i)
{
in>>x;
update(1,1,N,i,x);
}
out.open("arbint.out");
for(;M--;)
{
in>>x>>a>>b;
if(x) update(1,1,N,a,b);
else out<<query(1,1,N,a,b)<<'\n';
}
in.close();
out.close();
}