#include <fstream>
using namespace std ;
ifstream cin ("arbint.in") ;
ofstream cout ("arbint.out") ;
const int MAX = 1e5 + 14 ;
int arb [MAX << 4] ;
void update (int nod, int st, int dr, int pos, int val) {
if (st == dr) {
arb [nod] = val ;
return ;
}
int mij = (st + dr) >> 1 ;
if (pos <= mij) {
update (nod * 2, st, mij, pos, val) ;
}
else {
update (nod * 2 + 1, mij + 1, dr, pos, val) ;
}
arb [nod] = max(arb [nod * 2], arb [nod * 2 + 1]) ;
}
int query (int nod, int st, int dr, int a, int b) {
if (a <= st and dr <= b) {
return arb [nod] ;
}
int mij = (st + dr) >> 1 ;
int left_son = 0 ;
int right_son = 0 ;
if (a <= mij) {
left_son = query (nod * 2, st, mij, a, b) ;
}
if (b > mij) {
right_son = query (nod * 2 + 1, mij + 1, dr, a , b) ;
}
return max (left_son, right_son) ;
}
int main ()
{
int n, m ;
cin >> n >> m ;
for (int i = 1 ; i <= n ; ++ i) {
int x ;
cin >> x ;
update (1, 1, n, i, x) ;
}
while (m --) {
int tip, a, b ;
cin >> tip >> a >> b ;
if (tip == 0) {
cout << query (1, 1, n, a, b) << '\n' ;
}
else {
update (1, 1, n, a, b) ;
}
}
return 0 ;
}