#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define trace1(x) cerr<<#x<<": "<<x<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
typedef long long ll;
const int N=1e6+5;
int n, q;
long long a[N];
long long bit[N][2];
void update(int i, int id, int x)
{
while(i<=n)
{
bit[i][id]+=x;
i+=(i&(-i));
}
}
long long prefsum(int i, int id)
{
long long ans=0;
while(i>0)
{
ans+=bit[i][id];
i-=(i&(-i));
}
return ans;
}
long long rsum(int i, int j, int id)
{
return prefsum(j, id) - prefsum(i-1, id);
}
int main()
{
cin>>n>>q;
for(int i=1;i<=n;i++)
{
cin>>a[i];
update(i, a[i]%2, a[i]);
}
for(int i=1;i<=q;i++)
{
int type;
cin>>type;
if(type==1)
{
int x,y;
cin>>x>>y;
update(x, a[x]%2, -1*a[x]);
a[x]+=y;
update(x, a[x]%2, a[x]);
}
else
{
int L,R,x;
cin>>L>>R>>x;
cout<<rsum(L, R, x)<<endl;
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKI2RlZmluZ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