#include <bits/stdc++.h>
using namespace std;
ifstream in("arbint.in");
ofstream out("arbint.out");
const int NMAX = 100000;
int n, m;
int aint[4 * NMAX + 2];
void update(int node, int st, int dr, int poz, int val)
{
if(st == dr)
{
aint[node] = val;
return;
}
int med = (st + dr) / 2;
if(poz <= med) update(2 * node, st, med, poz, val);
else update(2 * node + 1, med + 1, dr, poz, val);
aint[node] = max(aint[2 * node], aint[2 * node + 1]);
}
int query(int node, int st, int dr, int a, int b)
{
if(a <= st && dr <= b)
return aint[node];
int med = (st + dr) / 2, maxst = 0, maxdr = 0;
if(a <= med)
maxst = query(2 * node, st, med, a, b);
if(b > med)
maxdr = query(2 * node + 1, med + 1, dr, a, b);
return max(maxst, maxdr);
}
int main()
{
in >> n >> m;
int c, a, b;
for(int i = 1; i <= n; i++)
{
in >> c;
update(1, 1, n, i, c);
}
while(m--)
{
in >> c >> a >> b;
if(c == 0)
out << query(1, 1, n, a, b) << '\n';
else
update(1, 1, n, a, b);
}
return 0;
}