/*
		Panama sum - editorial




*/

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
 
// #define fisier 1 
 
using namespace std;
 
typedef long long ll;
 
const int mod = 1000000007;
const double PI = 3.14159265359; 
const double eps = 1e-9;


int n, q, v[200002];

int main()
{
	#ifdef fisier
		ifstream cin("input.in");
		ofstream cout("output.out");
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> q;
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	
	
	for(int i = 1; i <= q; i++)
	{
		int tip, a, b;
		cin >> tip >> a >> b;
		if(tip == 1)
			v[a] = b;
		else if(tip == 3)
		{
			long long ans = -(1LL<<60);
			long long sum = 0;
			for(int j = a; j <= b; j++)
			{
				long long val = (j % 2 == 1 ? v[j] : -v[j]);
				if(j % 2 == 1)
					sum = max(sum + val, val);
				else
					sum = sum + val;
				ans = max(ans, sum);
			}
			sum = 0;
			for(int j = a; j <= b; j++)
			{
				long long val = (j % 2 == 0 ? v[j] : -v[j]);
				if(j % 2 == 0)
					sum = max(sum + val, val);
				else
					sum = sum + val;
				ans = max(ans, sum);
			}
			cout << ans << '\n';
		}
	}
	
	return 0;
}
