#include <bits/stdc++.h>
#define ll long long int
#define double long double
#define pb push_back
#define endl '\n'
#define er erase
#define sz size
#define in insert
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
using namespace std;
ll n, m, a[105], t[500];
void build(ll *a, ll v, ll tl, ll tr) /// building the sum segment tree
{
if(tl==tr)
{
t[v]=a[tl];
}
else
{
ll tm=(tl+tr)/2;
build(a, 2*v, tl, tm);
build(a, 2*v+1, tm+1, tr);
t[v]=max(t[2*v], t[2*v+1]);
}
}
void update(ll v, ll tl, ll tr, ll pos, ll val) /// changing the sum segment tree after updating a value in the array
{
if(tl==tr)
{
t[v]=val;
}
else
{
ll tm=(tl+tr)/2;
if(pos>tm)
{
update(2*v+1, tm+1, tr, pos, val);
}
else
{
update(2*v, tl, tm, pos, val);
}
t[v]=max(t[2*v], t[2*v+1]);
}
}
ll maxv(ll v, ll tl, ll tr, ll l, ll r) /// finding the sum of a subarray [l, r]
{
if(l>r)
return 0;
if(tl==l && tr==r)
{
return t[v];
}
ll tm=(tl+tr)/2;
///if(l>tm){tl=tm+1;return sum(2*v+1, tm+1, tr, l, r);} we do this check in the beginning( if(l>r) return 0 )
///else if(r<=tm){tr=tm;return sum(2*v, tl, tm, l, r);} we do this check in the beginning( if(l>r) return 0 )
return max(maxv(2*v+1, tm+1, tr, max(tm+1, l), r), maxv(2*v, tl, tm, l, min(tm, r)));
}
int32_t main(){
//ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ifstream fin("arbint.in");
ofstream fout("arbint.out");
fin>>n>>m;
for(ll i=0;i<n;i++)
fin>>a[i];
build(a, 1, 0, n-1);
while(m--)
{
ll x;
fin>>x;
if(x==1)
{
ll a, b;
fin>>a>>b;
update(1, 0, n-1, a-1, b);
}
else
{
ll a, b;
fin>>a>>b;
fout<<maxv(1, 0, n-1, a-1, b-1)<<endl;
}
}
return 0;
}