//Ilie Dumitru
#include<cstdio>
#include<algorithm>
const int NMAX=100005;
FILE* input=fopen("arbint.in", "r");
FILE* output=fopen("arbint.out", "w");
struct segTreeNode
{
int x;
friend segTreeNode operator+(segTreeNode a, segTreeNode b)
{
a.x=std::max(a.x, b.x);
return a;
}
};
struct segTree
{
int N;
segTreeNode v[NMAX<<2];
void init(int _N, segTreeNode* _v)
{
N=_N;
build(0, 0, N-1, _v);
}
void initDefault(int _N, segTreeNode& defaultVal)
{
N=_N;
buildDefault(0, 0, N-1, defaultVal);
}
void build(int node, int l, int r, segTreeNode* _v)
{
if(l==r)
{
v[node]=_v[l];
}
else
{
const int mid=l+((r-l)>>1);
build((node<<1)|1, l, mid, _v);
build((node<<1)+2, mid+1, r, _v);
v[node]=v[(node<<1)|1]+v[(node<<1)+2];
}
}
void buildDefault(int node, int l, int r, segTreeNode& defVal)
{
if(l==r)
{
v[node]=defVal;
}
else
{
const int mid=l+((r-l)>>1);
buildDefault((node<<1)|1, l, mid, defVal);
buildDefault((node<<1)+2, mid+1, r, defVal);
v[node]=v[(node<<1)|1]+v[(node<<1)+2];
}
}
segTreeNode query(int l, int r) {return query(0, 0, N-1, l, r);}
segTreeNode query(int node, int l, int r, int st, int dr)
{
if(st<=l && r<=dr)
return v[node];
const int mid=l+((r-l)>>1);
if(dr<=mid)
return query((node<<1)|1, l, mid, st, dr);
if(mid<st)
return query((node<<1)+2, mid+1, r, st, dr);
return query((node<<1)|1, l, mid, st, dr)+query((node<<1)+2, mid+1, r, st, dr);
}
void update(int pos, segTreeNode& x) {update(0, 0, N-1, pos, x);}
void update(int node, int l, int r, int pos, segTreeNode& x)
{
if(l==r)
v[node]=x;
else
{
const int mid=l+((r-l)>>1);
if(pos<=mid)
update((node<<1)|1, l, mid, pos, x);
else
update((node<<1)+2, mid+1, r, pos, x);
v[node]=v[(node<<1)|1]+v[(node<<1)+2];
}
}
};
segTree S;
segTreeNode init[NMAX];
int main()
{
FILE *f=fopen("arbint.in", "r");
FILE *g=fopen("arbint.out", "w");
int i, N, _, op, a, b;
segTreeNode x;
fscanf(f, "%d%d", &N, &_);
for(i=0;i<N;++i)
fscanf(f, "%d", &init[i].x);
S.init(N, init);
do
{
fscanf(f, "%d%d%d", &op, &a, &b);
if(op==0)
fprintf(g, "%d\n", S.query(a-1, b-1).x);
else
{
x.x=b;
S.update(a-1, x);
}
}while(--_);
fclose(f);
fclose(g);
return 0;
}