#include <fstream>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int n,i,j,op,l,r,q,solutie;
int Stree[400013];
void update (int nod, int st, int dr, int poz, int val)
{
if (st==dr) Stree[nod]=val;
else {
int middle=(st+dr)/2;
if (poz<=middle) update(nod*2,st,middle,poz,val);
else update(nod*2+1,middle+1,dr,poz,val);
Stree[nod]=max(Stree[nod*2],Stree[nod*2+1]);
}
}
void query ( int nod, int st, int dr, int a, int b)
{
if (st>=a && b>=dr) solutie=max(solutie,Stree[nod]);
else {
int middle=(st+dr)/2;
if (a<=middle) query(nod*2,st,middle,a,b);
if (b>middle) query(nod*2+1,middle+1,dr,a,b);
}
}
int main()
{
cin>>n>>q;
for (i=1;i<=n;++i)
{
cin>>op;
update(1,1,n,i,op);
}
while(q--)
{
cin>>op>>l>>r;
if (op==0){
solutie=-1<<30;
query(1,1,n,l,r);
cout<<solutie<<"\n";
}
if (op==1) update (1,1,n,l,r);
}
return 0;
}