1 #include<cstdio>
2 #include<iostream>
3 #include<cmath>
4 #include<cstring>
5 #include<set>
6 #include<map>
7 #include<queue>
8 #include<vector>
9 #include<cstdlib>
10 #define maxn 500000+1000
11 #define inf 1000000000
12 #define mod 1000000
13 using namespace std;
14 set<int>a,b;
15 map<int,int>mp;
16 priority_queue<int,vector<int>,greater<int> >q;
17 int n,m,st[maxn],ed[maxn];
18 inline int read()
19 {
20 int x=0,f=1;char ch=getchar();
21 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
22 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
23 return x*f;
24 }
25 void insert(int x)
26 {
27
28 mp[x]++;
29 if(mp[x]==1)a.insert(x);
30
31 }
32 void push(int x)
33 {
34 int l=*--b.lower_bound(x),r=*b.lower_bound(x);
35 q.push(min(x-l,r-x));
36 b.insert(x);
37 }
38 int main()
39 {
40 freopen("input.txt","r",stdin);
41 freopen("output.txt","w",stdout);
42 n=read();m=read();
43 b.insert(inf);b.insert(-inf);
44 for(int i=1;i<=n;i++)
45 {
46 int x=read();st[i]=ed[i]=x;push(x);
47 }
48 for(int i=2;i<=n;i++)insert(abs(st[i]-st[i-1]));
49 char ch[12];int x,y,z;
50 for(int i=1;i<=m;i++)
51 {
52 scanf("%s",ch);
53 if(ch[0]==‘I‘)
54 {
55 x=read();y=read();
56 if(x!=n)
57 {
58 z=abs(st[x+1]-ed[x]);
59 mp[z]--;
60 if(!mp[z])a.erase(z);
61 }
62 insert(abs(st[x+1]-y));
63 insert(abs(y-ed[x]));
64 ed[x]=y;push(y);
65 }else if(ch[4]==‘S‘)printf("%d\n",q.top());
66 else printf("%d\n",*a.begin());
67 }
68 return 0;
69 }