// Sergey Kopeliovich (aka Burunduk1)
// 26.10.2009
// dynamic interval tree

#include <cstdio>

typedef long long ll;

struct tree
{
  ll sum;
  int l, r;
};

const int MAX = 1 << 30;
const int maxt = (int)1e7;
const int mod = (int)1e9;

tree t[maxt];
int root = 1, pos = 2;

void Add( int &v, int vl, int vr, int i, int x )
{
  if (v == 0)
    v = pos++;
  if (i < vl || vr < i)
    return;
  if (vl != vr)
  {
    int vm = (vl + vr) / 2;
    Add(t[v].l, vl, vm, i, x);
    Add(t[v].r, vm + 1, vr, i, x);
    t[v].sum = t[t[v].l].sum + t[t[v].r].sum;
  }
  else
    t[v].sum = x;
}     

ll Get( int v, int vl, int vr, int l, int r )
{
  if (v == 0 || vr < l || r < vl)
    return 0;
  if (l <= vl && vr <= r)
    return t[v].sum;
  return Get(t[v].l, vl, (vl + vr) / 2, l, r) + Get(t[v].r, (vl + vr) / 2 + 1, vr, l, r);
}

int main()
{
  freopen("sum2.in", "r", stdin);
  freopen("sum2.out", "w", stdout);

  int n;
  ll last = 0;
  scanf("%d", &n);
  while (n--)
  {
    char ch;
    scanf(" %c", &ch);
    if (ch == '+')
    {
      int i;
      scanf("%d", &i);
      i = (i + last) % mod;
      Add(root, 0, MAX - 1, i, i);
      last = 0;
    }
    else
    { 
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%I64d\n", last = Get(root, 0, MAX - 1, l, r));
    }
  }
  return 0;
}