#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
int t[400002];
void update(int nod, int st, int dr, int poz, int x)
{
if (st == dr)
{
t[nod] = x;
return;
}
int mij = (st + dr) / 2;
if (poz <= mij)
update(2 * nod, st, mij, poz, x);
else
update(2 * nod + 1, mij + 1, dr, poz, x);
t[nod] = max(t[2 * nod], t[2 * nod + 1]);
}
int query(int nod, int st, int dr, int a, int b)
{
if (a > dr || b < st)
return 0;
if (a <= st && b >= dr)
return t[nod];
int mij = st + (dr - st) / 2;
return max(query(2 * nod, st, mij, a, b), query(2 * nod + 1, mij + 1, dr, a, b));
}
int main()
{
int x, op, a, b, m, n;
fin >> n >> m;
for (int i = 1; i <= n; i++)
{
fin >> x;
update(1, 1, n, i, x);
}
while (m--)
{
fin >> op >> a >> b;
if (op == 0)
fout << query(1, 1, n, a, b) << '\n';
else
update(1, 1, n, a, b);
}
return 0;
}