// Readiz lesson: complete C++17 local exercise.
#include <vector>
using namespace std;

struct FenwickTree {
    int n;
    vector<long long> tree;

    FenwickTree(int n) : n(n), tree(n + 1, 0) {}

    FenwickTree(const vector<long long>& values) {
        n = (int)values.size();
        tree.assign(n + 1, 0);
        for (int i = 0; i < n; ++i) {
            add(i + 1, values[i]);
        }
    }

    void add(int idx, long long delta) {
        while (idx <= n) {
            tree[idx] += delta;
            idx += idx & -idx;
        }
    }

    long long prefixSum(int idx) const {
        long long result = 0;
        while (idx > 0) {
            result += tree[idx];
            idx -= idx & -idx;
        }
        return result;
    }

    long long rangeSum(int l, int r) const {
        return prefixSum(r) - prefixSum(l - 1);
    }

    void setValue(int idx, long long oldValue, long long newValue) {
        add(idx, newValue - oldValue);
    }
int lowerBound(long long target) const {
    if (target <= 0) return 1;
    if (target > prefixSum(n)) return n + 1;

    int idx = 0;
    int bit = 1;
    while (bit <= n / 2) bit <<= 1;

    for (; bit > 0; bit >>= 1) {
        int next = idx + bit;
        if (next <= n && tree[next] < target) {
            idx = next;
            target -= tree[next];
        }
    }
    return idx + 1;
}
};

#include <iostream>
#include <string>
int main(int argc,char **argv) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    bool select=argc==2 && string(argv[1])=="--select";
    if(argc!=1 && !select)return 1;
    int n,q;
    if(!(cin>>n>>q) || n<1 || n>200000 || q<0 || q>200000)return 1;
    vector<long long>values(n);
    for(auto &v:values)if(!(cin>>v) || v < (select?0:-1000000000LL) || v>1000000000LL)return 1;
    FenwickTree tree(values);
    vector<long long>answers;
    for(int j=0;j<q;j++) {
        if(select) {
            long long target;
            if(!(cin>>target) || target < -1000000000000000LL || target > 1000000000000000LL)return 1;
            answers.push_back(tree.lowerBound(target));continue;
        }
        char operation;int l;long long r;
        if(!(cin>>operation>>l>>r) || l<1 || l>n)return 1;
        if(operation=='A') {
            if(r < -1000000000LL || r>1000000000LL)return 1;
            tree.add(l,r);
        } else if(operation=='S') {
            if(r<l || r>n)return 1;
            answers.push_back(tree.rangeSum(l,(int)r));
        } else return 1;
    }
    for(auto answer:answers)cout<<answer<<'\n';
}
