#include <stdio.h>
#include <math.h>
#define max(a, b) ((a > b) ? a : b)
static long H[240000], N = 2;
static void update(long i, long x)
{
long nod = N + i;
H[N + i] = x;
while (nod >>= 1)
H[nod] = max(H[nod << 1], H[(nod << 1) + 1]);
}
static long query(long nod, long st, long dr, long a, long b)
{
long mid, s, d;
if (a <= st && dr <= b)
return H[nod];
else {
mid = st + ((dr - st) >> 1);
s = d = 0;
if (a <= mid)
s = query(2 * nod, st, mid, a, b);
if (b > mid)
d = query(2 * nod + 1, mid + 1, dr, a, b);
return max(s, d);
}
}
int main(void)
{
long n, m, op, a, b, i;
freopen("arbint.in", "r", stdin);
freopen("arbint.out", "w", stdout);
scanf("%ld %ld", &n, &m);
a = n;
while (a >>= 1)
N <<= 1;
for (i = 0; i < n; i++) {
scanf("%ld", &H[N + i]);
update(i, H[N + i]);
}
while (m--) {
scanf("%ld %ld %ld", &op, &a, &b);
if (op == 0)
printf("%ld\n", query(1, 0, N - 1, a - 1, b - 1));
else
update(a - 1, b);
}
return 0;
}