#include <iostream>
using namespace std;
#define int long long int
const int N = 2e5+10;
int arr[N];
int segTree[4*N+1];
void buildSegTree(int idx, int low, int high){
if(low == high){
segTree[idx] = 0;
return;
}
int mid = (low + high) >> 1;
buildSegTree(2*idx, low, mid);
buildSegTree(2*idx+1, mid+1, high);
segTree[idx] = segTree[2*idx]+segTree[2*idx+1];
}
void updateSegTreePoint(int idx, int low, int high, int index, int val){
if(index<low or index>high){
return;
}
if(low == high){
segTree[idx] += val;
return;
}
int mid = (low+high)>>1;
if(index <= mid){
updateSegTreePoint(2*idx, low, mid, index, val);
} else {
updateSegTreePoint(2*idx+1, mid+1, high, index, val);
}
segTree[idx] = segTree[2*idx]+segTree[2*idx+1];
}
int querySegTree(int idx, int low, int high, int qs, int qe){
if(qs <= low and high <= qe){
return segTree[idx];
}
if(qe<low or qs>high or low>high){
return 0;
}
int mid = (low+high)>>1;
int left = querySegTree(2*idx, low, mid, qs, qe);
int right = querySegTree(2*idx+1, mid+1, high, qs, qe);
return left+right;
}
int32_t main() {
int n, q;
cin >> n >> q;
for(int i=0; i<n; i++){
cin>>arr[i];
}
buildSegTree(1, 0, n-1);
while(q--){
int t;
cin>>t;
if(t==1){
int a,b,u;
cin>>a>>b>>u;
updateSegTreePoint(1, 0, n-1, a-1, u);
updateSegTreePoint(1, 0, n-1, b, -u);
} else {
int k;
cin>>k;
cout << querySegTree(1, 0, n-1, 0, k-1)+arr[k-1] << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGludCBsb25nIGxvbmcgaW50CmNvbnN0IGludCBOID0gMmU1KzEwOwogCmludCBhcnJbTl07CmludCBzZWdUcmVlWzQqTisxXTsKIAp2b2lkIGJ1aWxkU2VnVHJlZShpbnQgaWR4LCBpbnQgbG93LCBpbnQgaGlnaCl7CglpZihsb3cgPT0gaGlnaCl7CgkJc2VnVHJlZVtpZHhdID0gMDsKCQlyZXR1cm47Cgl9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