#include <stdio.h>
#define max(a, b) a > b ? a : b
int sir[400050];
void update(int nod, int st, int dr, int pos, int val)
{
if(st == dr && st == pos)
{
sir[nod] = val;
return;
}
int half = (st + dr) / 2;
if(pos <= half)
update(2 * nod, st, half, pos, val);
else
update(2 * nod + 1, half + 1, dr, pos, val);
sir[nod] = max(sir[2 * nod + 1], sir[2 * nod]);
}
int maxint(int nod, int st, int dr, int a, int b)
{
if(a <= st && dr <= b)
return sir[nod];
int x=0, y=0, half = (st + dr) / 2;
if(a <= half)
x = maxint(2 * nod, st, half, a, b);
if(b >= half + 1)
y = maxint(2 * nod + 1, half + 1, dr, a, b);
return max(x, y);
}
int main()
{
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
int n, m, i, a, b, q;
scanf("%d %d", &n, &m);
for(i = 1;i <= n;i++)
{
scanf("%d", &q);
update(1, 1, n, i, q);
}
for(i = 0;i < m;i++)
{
scanf("%d %d %d", &q, &a, &b);
if(q)
update(1, 1, n, a, b);
else
printf("%d\n", maxint(1, 1, n, a, b));
}
return 0;
}