#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
using namespace std;
typedef long long longs;
int ST[4001], Add[4001];
void Update(int k, int L, int R, int i, int j, int v)
{
if (L > j || R < i) return;
if (i <= L && R <= j)
{
ST[k] += v;
Add[k] += v;
return;
}
Add[k << 1] += Add[k];
Add[(k << 1) + 1] += Add[k];
ST[k << 1] += Add[k];
ST[(k << 1) + 1] += Add[k];
Add[k] = 0;
int mid = (L + R) >> 1;
Update(k << 1, L, mid, i, j, v);
Update((k << 1) + 1, mid + 1, R, i, j, v);
ST[k] = max(ST[k << 1], ST[(k << 1) + 1]);
}
int Get(int k, int L, int R, int i, int j)
{
if (L > j || R < i) return -1000000000;
if (i <= L && R <= j) return ST[k];
Add[k << 1] += Add[k];
Add[(k << 1) + 1] += Add[k];
ST[k << 1] += Add[k];
ST[(k << 1) + 1] += Add[k];
Add[k] = 0;
int mid = (L + R) >> 1;
return max(Get(k << 1, L, mid, i, j), Get((k << 1) + 1, mid + 1, R, i, j));
}
int main()
{
int N, M, k, x, y, v;
cin >> N >> M;
while (M--)
{
cin >> k >> x >> y;
if (k) cout << Get(1, 1, N, x, y) << endl; else
{
cin >> v;
Update(1, 1, N, x, y, v);
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDxzZXQ+CgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGN0eXBlLmg+Cgp1c2luZyBuYW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wogICAgcmV0dXJuIG1heChHZXQoayA8PCAxLCBMLCBtaWQsIGksIGopLCBHZXQoKGsgPDwgMSkgKyAxLCBtaWQgKyAxLCBSLCBpLCBqKSk7Cn0KCmludCBtYWluKCkKewogICAgaW50IE4sIE0sIGssIHgsIHksIHY7CgogICAgY2luID4+IE4gPj4gTTsKICAgIHdoaWxlIChNLS0pCiAgICB7CiAgICAgICAgY2luID4+IGsgPj4geCA+PiB5OwogICAgICAgIGlmIChrKSBjb3V0IDw8IEdldCgxLCAxLCBOLCB4LCB5KSA8PCBlbmRsOyBlbHNlCiAgICAgICAgewogICAgICAgICAgICBjaW4gPj4gdjsKICAgICAgICAgICAgVXBkYXRlKDEsIDEsIE4sIHgsIHksIHYpOwogICAgICAgIH0KICAgIH0KCiAgICByZXR1cm4gMDsKfQo=