#include <iostream>
#include <fstream>
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n,m,i,j,nr,x,a,b;
unsigned long long v[500010];
void update(int nod,int st,int dr,int poz,int val)
{
if (st==dr) v[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);
v[nod]=max(v[nod*2],v[nod*2+1]);
}
}
int query(int nod,int st,int dr,int a,int b)
{
int x1=0,x2=0;
if (a<=st && dr<=b) return v[nod];
else
{
int m=(st+dr)/2;
if (a<=m) x1=query(2*nod,st,m,a,b);
if (b>=m+1) x2=query(2*nod+1,m+1,dr,a,b);
return max(x1,x2);
}
}
int main()
{
f>>n>>m;
for (i=1; i<=n; i++)
{
f>>x;
update(1,1,n,i,x);
}
for (i=1; i<=m; i++)
{
f>>x>>a>>b;
if (x==0) g<<query(1,1,n,a,b)<<'\n';
else update(1,1,n,a,b);
}
return 0;
}