#include <fstream>
#include <algorithm>
using namespace std;
ifstream cin("arbint.in");
ofstream cout("arbint.out");
#define NMAX 100001
int arbore[4 * NMAX], n, i, x, m, y, z;
static inline void update(int a, int b, int nod, int poz, int val) {
if(a == b)
arbore[nod] = val;
else {
int mid = (a + b) / 2;
if(poz <= mid)
update(a, mid, nod * 2, poz, val);
else update(mid + 1, b, nod * 2 + 1, poz, val);
arbore[nod] = max(arbore[nod * 2], arbore[nod * 2 + 1]);
}
}
static inline int maxim(int a, int b, int nod, int st, int dr) {
int x1 = 0;
int x2 = 0;
if(st <= a && b <= dr)
return arbore[nod];
int mid = (a + b) / 2;
if(st <= mid)
x1 = maxim(a, mid, nod * 2, st, dr);
if(mid < dr)
x2 = maxim(mid + 1, b, nod * 2 + 1, st, dr);
return max(x1, x2);
}
int main() {
cin >> n >> m;
for(i = 1; i <= n; i++) {
cin >> x;
update(1, n, 1, i, x); //actualizez maximul pe fiecare interval
}
for(i = 1; i <= m; i++) {
cin >> x >> y >> z;
if(x == 0)
cout << maxim(1, n, 1, y, z) << '\n';
else update(1, n, 1, y, z);
}
return 0;
}