#include <fstream>
#include <vector>
#include <algorithm>
#include <limits>
#define INF numeric_limits<int>::max()
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
class SegmentTree{
private:
vector<int> tree;
int dim;
public:
void set_dimension(int n)
{
dim=n;
tree=vector<int> (4*dim+1);
}
void update(int x,int left,int right,int pos,int val)
{
if(left==right)tree[x]=val;
else{
int mid=(left+right)/2;
if(pos<=mid)update(2*x,left,mid,pos,val);
else update(2*x+1,mid+1,right,pos,val);
tree[x]=max(tree[2*x],tree[2*x+1]);
}
}
int get_max(int x,int left,int right,int a,int b)
{
if(a<=left && b>=right)return tree[x];
else{
int mid=(left+right)/2,mx=-INF;
if(a<=mid)mx=max(mx,get_max(2*x,left,mid,a,b));
if(b>mid)mx=max(mx,get_max(2*x+1,mid+1,right,a,b));
return mx;
}
}
};
SegmentTree ST;
int n,q;
int main()
{
in>>n>>q;
ST.set_dimension(n);
for(int i=1;i<=n;i++)
{
int x;
in>>x;
ST.update(1,1,n,i,x);
}
for(;q;q--)
{
int t,x,y;
in>>t>>x>>y;
if(t==0)
out<<ST.get_max(1,1,n,x,y)<<'\n';
else
ST.update(1,1,n,x,y);
}
return 0;
}