#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,root,cnt;
struct node {
int val,ch[2],siz,minn,delta,a,rev,fa;
} tree[1000001];
void update(int o) {
int l=tree[o].ch[0],r=tree[o].ch[1];
tree[o].siz=1;
tree[o].minn=tree[o].val;
if(l) {
tree[o].minn=min(tree[o].minn,tree[l].minn);
tree[o].siz+=tree[l].siz;
}
if(r) {
tree[o].minn=min(tree[o].minn,tree[r].minn);
tree[o].siz+=tree[r].siz;
}
}
void change(int o,int val) {
tree[o].val+=val;
tree[o].minn+=val;
tree[o].delta+=val;
}
void reverse(int o) {
swap(tree[o].ch[0],tree[o].ch[1]);
tree[o].rev^=1;
}
void pushdown(int o) {
int l=tree[o].ch[0],r=tree[o].ch[1];
if(tree[o].delta) {
change(l,tree[o].delta);
change(r,tree[o].delta);
tree[o].delta=0;
}
if(tree[o].rev) {
reverse(l);
reverse(r);
tree[o].rev=0;
}
}
int build(int l,int r) {
int cow;
if(l>r) return 0;
if(l==r) {
cow=++cnt;
tree[cow].val=tree[cow].minn=tree[l].a;
tree[cow].siz=1;
return cow;
}
int mid=l+r>>1;
cow=++cnt;
tree[cow].val=tree[cow].minn=tree[mid].a;
tree[cow].ch[0]=build(l,mid-1);
tree[cow].ch[1]=build(mid+1,r);
tree[tree[cow].ch[0]].fa=cow;
tree[tree[cow].ch[1]].fa=cow;
update(cow);
return cow;
}
int get(int x) {
return tree[tree[x].fa].ch[1]==x;
}
void Rotate(int x) {
int y=tree[x].fa,z=tree[y].fa;
pushdown(y);
pushdown(x);
int w=get(x);
tree[y].ch[w]=tree[x].ch[w^1];
tree[tree[x].ch[w^1]].fa=y;
tree[x].ch[w^1]=y;
tree[y].fa=x;
tree[x].fa=z;
if(z)
tree[z].ch[tree[z].ch[1]==y]=x;
update(y);
update(x);
}
void splay(int x,int val) {
for(int f; (f=tree[x].fa)!=val; Rotate(x)) {
if(tree[f].fa!=val) Rotate(get(f)==get(x)?f:x);
}
if(!val) root=x;
}
int find(int x) {
int cow=root;
while(1) {
pushdown(cow);
if(x<=tree[tree[cow].ch[0]].siz) cow=tree[cow].ch[0];
else {
x-=tree[tree[cow].ch[0]].siz;
if(x==1) return cow;
x--;
cow=tree[cow].ch[1];
}
}
}
int pre() {
pushdown(root);
int cow=tree[root].ch[0];
pushdown(cow);
while(tree[cow].ch[1]) {
cow=tree[cow].ch[1];
pushdown(cow);
}
return cow;
}
void clear(int x) {
tree[x].ch[1]=tree[x].ch[0]=tree[x].fa=0;
}
void Delete(int x) {
x=find(x+1);
splay(x,0);
if(!tree[root].ch[0]&&!tree[root].ch[1]) {
clear(root);
root=0;
return ;
}
if(!tree[root].ch[0]) {
int p=root;
root=tree[root].ch[1];
tree[root].fa=0;
clear(p);
return ;
}
if(!tree[root].ch[1]) {
int p=root;
root=tree[root].ch[0];
tree[root].fa=0;
clear(p);
return ;
}
int t=pre(),p=root;
splay(t,0);
tree[root].ch[1]=tree[p].ch[1];
tree[tree[p].ch[1]].fa=root;
clear(p);
update(root);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
tree[1].a=tree[n+2].a=0x3f3f3f3f3f3f3f;
for(int i=2; i<=n+1; i++) cin>>tree[i].a;
root=build(1,n+2);
cin>>m;
for(int i=1; i<=m; i++) {
char ch[101];
int x,y,k;
cin>>ch;
if(ch[0]=='D') {
cin>>x;
Delete(x);
} else if(ch[0]=='A') {
cin>>x>>y>>k;
int fx=find(x),fy=find(y+2);
splay(x,0);
splay(fy,fx);
change(tree[tree[root].ch[1]].ch[0],k);
update(tree[root].ch[1]);
update(root);
} else if(ch[0]=='M') {
cin>>x>>y;
int fx=find(x),fy=find(y+2);
splay(fx,0);
splay(fy,fx);
cout<<tree[tree[tree[root].ch[1]].ch[0]].minn<<'\n';
} else if(ch[0]=='I') {
cin>>x>>k;
int fx=find(x+1),fy=find(x+2);
splay(fx,0);
splay(fy,fx);
tree[tree[root].ch[1]].ch[0]=++cnt;
tree[cnt].fa=tree[root].ch[1];
tree[cnt].siz=1;
tree[cnt].minn=tree[cnt].val=k;
update(tree[root].ch[1]);
update(root);
} else if(ch[0]=='R'&&ch[3]=='E') {
cin>>x>>y;
int fx=find(x),fy=find(y+2);
splay(fx,0);
splay(fy,fx);
reverse(tree[tree[root].ch[1]].ch[0]);
} else if(ch[0]=='R'&&ch[3]=='O') {
cin>>x>>y>>k;
int len=y-x+1;
k=(k%len+len)%len;
if(!k) continue;
int fx=find(y+1-k),fy=find(y+2);
splay(fx,0);
splay(fy,fx);
int t=tree[tree[root].ch[1]].ch[0];
tree[t].fa=0;
tree[tree[root].ch[1]].ch[0]=0;
update(tree[root].ch[1]);
update(root);
fx=find(x);
fy=find(x+1);
splay(fx,0);
splay(fy,fx);
tree[tree[root].ch[1]].ch[0]=t;
tree[t].fa=tree[root].ch[1];
update(tree[root].ch[1]);
update(root);
}
}
}