#include <fstream>
#include <cstdlib>
using namespace std;
const int N_MAX=262144;
int Aint[N_MAX];
inline int _max(int x, int y) {return x >= y ? x : y;}
inline void Update(int vertex, int left, int right, const int& xIndex, const int& xValue)
{
if(left == right)
Aint[vertex]=xValue;
else {
int middle=(left+right)>>1;
if(xIndex <= middle)
Update(vertex<<1, left, middle, xIndex, xValue);
else Update((vertex<<1)|1, middle+1, right, xIndex, xValue);
Aint[vertex]=_max(Aint[vertex<<1], Aint[(vertex<<1)|1]);
}
}
inline int Query(int vertex, int left, int right, const int& start, const int& end)
{
if(left >= start && right <= end)
return Aint[vertex];
else {
int middle=(left+right)>>1, m1=0, m2=0;
if(start <= middle)
m1=Query(vertex<<1, left, middle, start, end);
if(middle < end)
m2=Query((vertex<<1)|1, middle+1, right, start, end);
return _max(m1, m2);
}
}
int main()
{
int N, M, i, x, op, a, b;
ifstream in("arbint.in");
ofstream out("arbint.out");
in>>N>>M;
for(i=1; i <= N; ++i)
{
in>>x;
Update(1, 1, N, i, x);
}
for(; M; --M)
{
in>>op>>a>>b;
if(0 == op)
out<<Query(1, 1, N, a, b)<<'\n';
else Update(1, 1, N, a, b);
}
return EXIT_SUCCESS;
}