#include <fstream>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int NMAX = 100000;
const int ARBMAX = 2*NMAX + 10;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int arb[2*NMAX + 10];
void insert(int nod, int left, int right, int pos, int newValue) {
if (left != right) {
int mid = (left + right)/2;
if (pos <= mid) insert(2*nod, left, mid, pos, newValue);
else insert(2*nod + 1, mid + 1, right, pos, newValue);
arb[nod] = max(arb[2*nod], arb[2*nod+1]);
} else arb[nod] = newValue;
}
int query(int nod, int left, int right, int a, int b) {
if (a>right || b<left) return 0; // minvalue
if (a<=left && b>=right) return
arb[nod];
else {
int mid = (left + right)/2;
return max(query(2*nod, left, mid, a, b),
query(2*nod + 1, mid +1, right, a, b));
}
return 0;
}
int main() {
int n, m;
fin >> n;
fin >> m;
for (int i=0; i<n; i++) {
int x;
fin >> x;
insert(1, 0, n-1, i, x);
}
for (int i=0; i<m; i++) {
int op, a, b;
fin >> op >> a >> b;
switch (op) {
case 0:
fout << query(1, 0, n-1, a-1, b-1) << endl;
break;
case 1:
insert(1, 0, n-1, a-1, b);
break;
}
}
return 0;
}