#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("datorii.in");
ofstream fout("datorii.out");
int n, m;
vector<int> v;
vector<int> aint;
void init() {
v = vector<int>(n + 1);
aint = vector<int>(4 * n + 1);
}
void build(int node, int left, int right) {
if (left == right) {
aint[node] = v[left];
return;
}
int mid = (left + right) / 2;
build(2 * node, left, mid);
build(2 * node + 1, mid + 1, right);
aint[node] = aint[2 * node] + aint[2 * node + 1];
}
void read() {
fin >> n >> m;
init();
for (int i = 1; i <= n; ++i) {
fin >> v[i];
}
build(1, 1, n);
}
void update(int node, int left, int right, const int& position, const int& value) {
if (left == right) {
aint[node] -= value;
return;
}
int mid = (left + right) / 2;
if (position <= mid) {
update(2 * node, left, mid, position, value);
}
else {
update(2 * node + 1, mid + 1, right, position, value);
}
aint[node] = aint[2 * node] + aint[2 * node + 1];
}
int query(int node, int left, int right, const int& queryLeft, const int& queryRight) {
if (queryLeft <= left && right <= queryRight) {
return aint[node];
}
int mid = (left + right) / 2;
int leftResult = 0, rightResult = 0;
if (queryLeft <= mid) {
leftResult = query(2 * node, left, mid, queryLeft, queryRight);
}
if (mid + 1 <= queryRight) {
rightResult = query(2 * node + 1, mid + 1, right, queryLeft, queryRight);
}
return leftResult + rightResult;
}
void solve() {
int op, x, y;
while (m--) {
fin >> op >> x >> y;
if (op == 0) {
update(1, 1, n, x, y);
}
else {
fout << query(1, 1, n, x, y) << '\n';
}
}
}
int main()
{
read();
solve();
return 0;
}