#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("arbint.in");
ofstream fout("arbint.out");
const int MAXN = 100000;
int v[4 * MAXN];
void build_segm_tree(int arr[], int nod, int left, int right)
{
if (left == right)
{
v[nod] = arr[left];
}
else
{
build_segm_tree(arr, 2 * nod, left, (left + right) / 2);
build_segm_tree(arr, 2 * nod + 1, (left + right) / 2 + 1, right);
v[nod] = max(v[2 * nod], v[2 * nod + 1]);
}
}
int maxim(int nod, int L, int R, int left_index, int right_index) //left si right index sunt de unde pana unde se cere suma
{
if (right_index < L || left_index > R)
return 0;
if (left_index <= L && R <= right_index) //intervalul este continut
{
return v[nod];
}
else return max(maxim(2 * nod, L, (L + R) / 2, left_index, right_index), maxim(2 * nod + 1, (L + R) / 2 + 1, R, left_index, right_index));
}
void update(int nod, int L, int R, int poz, int val)
{
if (poz < L || poz > R) return;
if (L == R) { v[nod] = val; return; }
update(2 * nod, L, (L + R) / 2, poz, val);
update(2 * nod + 1, (L + R) / 2 + 1, R, poz, val);
v[nod] = max(v[nod * 2], v[nod * 2 + 1]);
}
int main()
{
int N, M, op, a, b;
fin >> N >> M;
int* arr = new int[N + 1];
for (int i = 1; i <= N; ++i)
fin >> arr[i];
build_segm_tree(arr, 1, 1, N);
for (int i = 1; i <= M; ++i)
{
fin >> op >> a >> b;
if (op == 0)
{
fout << maxim(1, 1, N, a, b)<<'\n';
}
else
{
update(1, 1, N, a, b);
}
}
return 0;
}