#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

int n,q;
int sc[2000001];
int data[2000001];
int data2[2000001],data2_cnt[2000001],cnt2;

struct leader{
	int s;
	int n;
};

bool comp(const leader& l1,const leader& l2){
	return l1.s<l2.s;
};

int l_flag[2000001],l_num;

leader l[2000001];

bool check(int range,int x){
	int cnt=0;
	int r=0;
	for(int i=0;i<l_num;i++){
		if(l_flag[l[i].n]==1){
			int nl=lower_bound(data2,data2+cnt2,l[i].s-range)-data2;
			int nr=lower_bound(data2,data2+cnt2,l[i].s)-data2;
			if(nl>r)cnt+=data2_cnt[nl-1]-data2_cnt[r];
			r=nr;
		}
	}
	cnt+=n-data2_cnt[r];
	if(cnt>x)return false;
	return true;
}

int query(int x){
	int l=-1,r=1200000001;
	for(int i=0;i<150;i++){
		int mid=(l+r)/2;
		if(check(mid,x))r=mid;
		else l=mid;
	}
	return r;
}

int main(void){
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++){
		scanf("%d",&sc[i]);
		data[i]=sc[i];
	}
	sort(data,data+n);
	data2[0]=-1;
	for(int i=0;i<n;i++){
		if(data2[cnt2]==data[i])data2_cnt[cnt2]++;
		else{
			cnt2++;
			data2_cnt[cnt2]=data2_cnt[cnt2-1]+1;
			data2[cnt2]=data[i];
		}
	}
	//for(int i=0;i<=n;i++)printf("%d%c",data2[i],i==n?'\n':' ');
	//for(int i=0;i<=n;i++)printf("%d%c",data2_cnt[i],i==n?'\n':' ');
	for(int i=0;i<q;i++){
		string s;
		int x;
		cin >> s >> x;
		if(s[0]=='A'){
			x--;
			l_flag[x]=1;
			l[l_num].n=x;
			l[l_num].s=sc[x];
			l_num++;
			sort(l,l+l_num,comp);
		}
		if(s[0]=='R'){
			x--;
			l_flag[x]=0;
		}
		if(s[0]=='C'){
			int ans=query(x);
			if(ans==1200000001)printf("NA\n");
			else printf("%d\n",ans);
		}
	}
	return 0;
}