#include <fstream>
using namespace std;
ofstream fout ("arbint.out");
ifstream fin ("arbint.in");
int ans,x,y,n,arb[ 4 * 100001 ],m,z,i;
void update( int nod , int cs , int cd , int poz ,int val )
{
int mij = ( cs + cd ) >> 1;
if( cs == cd )
{
arb[ nod ] = val;
return;
}
if( poz <= mij )
update( 2 * nod , cs , mij , poz , val );
else
update( 2 * nod + 1 , mij + 1 , cd , poz , val );
arb[ nod ] = max( arb[ 2 * nod ] , arb[ 2 * nod + 1 ] );
}
void query( int nod, int cs , int cd, int L , int R )
{
int mij = ( cs + cd ) >> 1;
if( L <= cs && R >= cd )
{
ans = max( ans , arb[ nod ] );
return;
}
if( cd < L || cs > R )
return;
query( 2 * nod , cs , mij , L , R );
query( 2 * nod + 1 , mij + 1 , cd , L , R );
}
int main ()
{
fin>>n>>m;
for( i = 1 ; i <= n ; i++ )
{
fin>>x;
update( 1 , 1 , n , i , x );
}
for( i = 1 ; i <= m ; i++ )
{
fin>>x>>y>>z;
if( x == 0 )
{
ans = 0;
query( 1 , 1 , n , y , z );
fout<<ans<<'\n';
}
else
{
update( 1 , 1 , n , y , z );
}
}
return 0;
}