#include <fstream>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
const int nmax=100000;
int arbint[4*nmax],n,op,m,a,b,x;
void update(int nod,int st,int dr, int poz,int val)
{
if (st==dr)
arbint[nod]=val;
else
{
int m=(st+dr)/2;
if (poz<=m)
update(2*nod,st,m,poz,val);
else update(2*nod+1,m+1,dr,poz,val);
arbint[nod]=max(arbint[2*nod],arbint[2*nod+1]);
}
}
int query(int nod, int st, int dr, int a, int b)
{
if (a==st && b==dr)
return arbint[nod];
int m=(st+dr)/2;
if (b<=m)
return query(2*nod,st,m,a,b);
if (a>=m+1)
return query(2*nod+1,m+1,dr,a,b);
return
max(query(2*nod,st,m,a,m),query(2*nod+1,m+1,dr,m+1,b));
}
int main()
{
cin>>n>>m;
for (int i=1;i<=n;i++)
{
cin>>x;
update(1,1,n,i,x);
}
while (m--)
{
cin>>op>>a>>b;
if (op==0)
{
cout<<query(1,1,n,a,b)<<"\n";
}
else
{
update(1,1,n,a,b);
}
}
return 0;
}