#include <fstream>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
int ST[400002];
int update(int nod, int from, int to, int poz, int val)
{
if(from==to) {ST[nod]=val; return 0;}
int mid=(from+to)/2;
if(poz<=mid) update(2*nod, from, mid, poz, val);
else update(2*nod+1, mid+1, to, poz, val);
ST[nod]=max(ST[2*nod], ST[2*nod+1]);
}
int query(int nod, int from, int to, int qleft, int qright)
{
int smax=0;
if(qleft<=from && to<=qright) return ST[nod];
int mid=(from+to)/2;
if(qleft<=mid)
{
int s=query(2*nod, from, mid, qleft, qright);
smax=max(smax, s);
}
if(mid+1<=qright)
{
int s=query(2*nod+1, mid+1, to, qleft, qright);
smax=max(smax, s);
}
return smax;
}
int main()
{
int n, m, i, x, a, b, val;
cin>>n>>m;
//ST.resize(4*n+2);
//v.resize(n+2);
for(i=1; i<=n; i++) cin>>x, update(1, 1, n, i, x);
for(i=1; i<=m; i++)
{
cin>>val>>a>>b;
if(val==0) cout<<query(1, 1, n, a, b)<<'\n';
else if(val==1) update(1, 1, n, a, b);
}
return 0;
}