#include <fstream>
#include <cstdlib>
#define N_MAX 262145
using namespace std;
int AInt[N_MAX];
inline int _max( int x, int y ) { return x >= y ? x : y; }
inline void Update( int vIndex, int left, int right, int& xIndex, int& xValue )
{
if( left == right )
AInt[vIndex]=xValue;
else {
int middle=(left+right)>>1;
if( xIndex <= middle )
Update( vIndex<<1, left, middle, xIndex, xValue );
else Update( (vIndex<<1)|1, middle+1, right, xIndex, xValue );
AInt[vIndex]=_max( AInt[vIndex<<1], AInt[(vIndex<<1)|1] );
}
}
inline int Query( int vIndex, int left, int right, int& start, int& end )
{
if( left >= start && right <= end )
return AInt[vIndex];
int middle=(left+right)>>1, a=0, b=0;
if( start <= middle )
a=Query( vIndex<<1, left, middle, start, end );
if( end > middle )
b=Query( (vIndex<<1)|1, middle+1, right, start, end );
return _max( a, b );
}
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 );
}
while( 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;
}