#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#define MaxSize 100005
using namespace std;
typedef long long ll;
ll sum[MaxSize * 4];
ll arr[MaxSize];
void merger(ll index)
{
sum[index] = sum[index << 1] + sum[index << 1 | 1];
}
void build(ll l, ll r, ll index)
{
if (l == r)
{
sum[index] = arr[l];
return;
}
ll mid = l + ((r - l) >> 1);
build(l, mid, index << 1);
build(mid + 1, r, index << 1 | 1);
merger(index);
}
void updateNodes(ll L, ll R, ll c, ll l, ll r, ll index)
{
if (l == r)
{
sum[index] += c;
return;
}
ll mid = l + ((r - l) >> 1);
if (L <= mid)updateNodes(L, R, c, l, mid, index << 1);
if (R > mid) updateNodes(L, R, c, mid + 1, r, index << 1 | 1);
merger(index);
}
ll querySum(ll L, ll R, ll l, ll r, ll index)
{
if (L <= l && r <= R)
{
return sum[index];
}
ll mid = l + ((r - l) >> 1);
ll ans = 0;
if (L <= mid) ans+=querySum(L, R, l, mid, index << 1);
if (R > mid)ans+=querySum(L, R, mid + 1, r, index << 1 | 1);
return ans;
}
int main()
{
ll n, m;
scanf("%lld %lld", &n, &m);
for (ll i = 1; i <= n; i++)
{
scanf("%lld", &arr[i]);
}
build(1, n, 1);
ll x, y, k, a;
while (m--)
{
scanf("%lld", &a);
switch (a)
{
case 1:
scanf("%lld %lld %lld", &x, &y, &k);
updateNodes(x, y, k, 1, n, 1);
break;
case 2:
scanf("%lld %lld", &x, &y);
printf("%lld\n", querySum(x, y, 1, n, 1));
default:
break;
}
}
return 0;
}