#include <fstream>
using namespace std;
#define MAX 100005
ifstream cin ("aib.in");
ofstream cout ("aib.out");
int n;
int v[MAX];
long long aib[MAX];
int m;
int c, a, b;
void update(int poz, int val)
{
while (poz <= n)
{
aib[poz] += val;
poz += (poz & (-poz));
}
}
long long query(int poz)
{
long long s = 0;
while (poz > 0)
{
s += aib[poz];
poz -= (poz & (-poz));
}
return s;
}
long long k = 0;
void cb(int a)
{
int st = 1;
int dr = n;
while(st <= dr)
{
int mij = (st + dr) / 2;
if (query(mij) < a)
{
st = mij + 1;
} else if (query(mij) > a)
{
dr = mij - 1;
} else if (query(mij) == a)
{
k = mij;
dr = mij - 1;
}
}
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
cin >> v[i];
update(i, v[i]);
}
for (int i = 1; i <= m; i++)
{
cin >> c;
if (c == 0)
{
cin >> a >> b;
update(a, b);
} else if (c == 1)
{
cin >> a >> b;
cout << query(b) - query(a - 1) << '\n';
} else
{
cin >> a;
k = 0;
cb(a);
cout << k << '\n';
}
}
return 0;
}