#include <bits/stdc++.h>
using namespace std;

mt19937 rng;
using ll = long long;

struct node
{
    int lson, rson;
    int x, y;
    int cnt;
    ll sum;

    node(): lson(-1), rson(-1), x(-1), y(-1),
    cnt(1), sum(-1)
    {}

    node(const int x_): lson(-1), rson(-1),
                        x(x_), y(rng()),
                        cnt(1), sum(x) {}
};

struct treap_manager
{
    vector<node> v;

    int get_cnt (const int root)
    {
        return root == -1 ? 0 : v[root].cnt;
    }
    ll get_sum (const int root)
    {
        return root == -1 ? 0 : v[root].sum;
    }

    void recalc (const int root)
    {
        v[root].cnt = 1 + get_cnt(v[root].lson) +
                      get_cnt(v[root].rson);
        v[root].sum = v[root].x +
                      get_sum(v[root].lson) +
                      get_sum(v[root].rson);
    }

    int merge(int l, int r)
    {
        if (l == -1)
            return r;
        if (r == -1)
            return l;

        if (v[l].y > v[r].y)
        {
            const int mem_size = get_cnt(r);
            v[l].rson = merge(v[l].rson, r);

            recalc(l);
            return l;
        }
        else
        {
            const int mem_size = get_cnt(l);
            v[r].lson = merge(l, v[r].lson);

            recalc(r);
            return r;
        }
    }

    pair<int, int> split(int t, int x)
    {
        if (t == -1)
            return {-1, -1};

        if (v[t].x < x)
        {
            int l, r;
            tie(l, r) = split(v[t].rson, x);
            v[t].rson = l;

            recalc(t);
            return {t, r};
        }
        else
        {
            int l, r;
            tie(l, r) = split(v[t].lson, x);
            v[t].lson = r;

            recalc(t);
            return {l, t};
        }
    }

    bool find(int &t, const int x)
    {
        int l, m, r;
        tie(l, m) = split(t, x);
        tie(m, r) = split(m, x + 1);

        const bool ok = (m != -1);
        t = merge(l, merge(m, r));
        return ok;
    }

    int get_new_node(const int x)
    {
        v.push_back(node(x));
        return int(v.size()) - 1;
    }

    void safe_insert (int &t, const int x)
    {
        if (find(t, x))
            return;

        insert(t, x);
    }

    void insert(int &t, const int x)
    {
        int l, r;
        tie(l, r) = split(t, x);
        const int m = get_new_node(x);
        t = merge(l, merge(m, r));
    }

    void erase(int &t, const int x)
    {
        int l, m, r;
        tie(l, m) = split(t, x);
        tie(m, r) = split(m, x + 1);
        t = merge(l, r);
    }

    int find_min(int t)
    {
        assert(t != -1);
        while (v[t].lson != -1)
            t = v[t].lson;
        return v[t].x;
    }

    void dfs (const int root, vector<int> &ans)
    {
        if (root == -1)
            return;

        dfs(v[root].lson, ans);
        ans.push_back(v[root].x);
        dfs(v[root].rson, ans);
    }

    vector<int> get_order (const int root)
    {
        vector<int> ans;
        dfs(root, ans);
        return ans;
    }

    int get_kth (const int root, const int k)
    {
        assert(0 <= k && k < get_cnt(root));
        const int left_size = get_cnt(v[root].lson);
        if (k == left_size)
            return v[root].x;
        if (k < left_size)
            return get_kth(v[root].lson, k);
        /// k > left_size;
        return get_kth(v[root].rson, k - left_size - 1);
    }

    void check_tree (const int root)
    {
        if (root == -1)
            return;

        assert(get_cnt(root) == 1 + get_cnt(v[root].lson) + get_cnt(v[root].rson));
        check_tree(v[root].lson);
        check_tree(v[root].rson);
    }

    void print_tree (const int root)
    {
        if (root == -1)
            return;

        cerr << root << ' ' << v[root].cnt << endl;
        cerr << v[root].lson << ' ' << v[root].rson << endl;
        cerr << "end vertex" << endl;

        print_tree(v[root].lson);
        print_tree(v[root].rson);
    }

    /// x in [lb, rb)
    ll get_sum (int &root, const int lb, const int rb)
    {
        int l, m, r;
        tie(l, m) = split(root, lb);
        tie(m, r) = split(m, rb);
        const ll ans = get_sum(m);

        root = merge(l, merge(m, r));
        return ans;
    }

    pair<int, int> split_by_k (int t, const int k)
    {
        assert(0 <= k && k <= get_cnt(t));
        if (t == -1)
            return {-1, -1};

        const int left_size = get_cnt(v[t].lson);
        if (left_size < k)
        {
            int l, r;
            tie(l, r) = split(v[t].rson, k - left_size - 1);
            v[t].rson = l;

            recalc(t);
            return {t, r};
        }
        else
        {
            int l, r;
            tie(l, r) = split(v[t].lson, k);
            v[t].lson = r;

            recalc(t);
            return {l, t};
        }
    }
};

void solve(istream &cin = std::cin,
           ostream &cout = std::cout)
{
    treap_manager manager;
    int root = -1;

    int n;
    cin >> n;

    const int bound = int(1e9);
    int last = 0;

    for (int i = 0; i < n; i++)
    {
        char type;
        cin >> type;

        if (type == '+')
        {
            int what;
            cin >> what;
            what = (what + last) % bound;
            manager.safe_insert(root, what);

            last = 0;
        }
        else if (type == '?')
        {
            int l, r;
            cin >> l >> r;

            const ll sum = manager.get_sum(root, l, r + 1);
            last = int(sum % bound);
            cout << sum << "\n";
        }
        else
            assert(false);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef LOCAL
    ifstream fin("input.txt");
    ofstream fout("output.txt");
    solve(fin, fout);
#else
    solve(cin, cout);
#endif
}
