#include <fstream>
#define lim 100004
using namespace std;
ifstream f("arbint.in");
ofstream g("arbint.out");
int n, m, x, op, a, b, tree[lim*4];
int query(int node, int low, int hi, int a, int b) {
if(a>hi || b<low)
return 0;
if(a<=low && b>=hi)
return tree[node];
int mid=(low+hi)/2, snode=node*2;
return max(query(snode, low, mid, a, b), query(snode+1, mid+1, hi, a, b));
}
void update(int node, int low, int hi, int pos, int val) {
if(low==hi) {
tree[node]=val;
return;
}
int mid=(low+hi)/2, snode=node*2;
if(pos<=mid) update(snode, low, mid, pos, val);
else update(snode+1, mid+1, hi, pos, val);
tree[node]=max(tree[snode], tree[snode+1]);
}
int main(){
f>>n>>m;
for(int i=1;i<=n;i++) {
f>>x;
update(1, 1, n, i, x);
}
for(int i=1;i<=m;i++) {
f>>op>>a>>b;
if(!op) g<<query(1, 1, n, a, b)<<'\n';
else update(1, 1, n, a, b);
}
return 0;
}