#include <cstdio>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

const int INF = (int)1e9;
const int SIZE = 1000000;

int s[SIZE],s_sort[SIZE];
multiset<int> leader;
int n,q;

int calc(int x){
  int l=0,r=1000000100,mid;
  int p,last;

  while(l<r){
    p = 0;
    mid = (l+r)/2;
    multiset<int>::iterator it = leader.begin(),it2;
    it2 = it;
    last = -1;
    
    for(;it!=leader.end();it++){
      if(last == *it) continue;
      p += (int)(upper_bound(s_sort,s_sort+n,*it)
		 -lower_bound(s_sort,s_sort+n,max(*it-mid,last+1)));
      //cerr << *it << "-" << max(*it-mid,last+1) << ":" << p <<  endl;
      last = *it;
    }

    //cerr << mid << ":" << x << " " <<  n-p << endl;
    if(n-p <= x){
      r = mid;
    }else{
      l = mid+1;
    }
  }

  return l;

}

int main(){

  scanf("%d%d",&n,&q);

  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
    s_sort[i] = s[i];
  }

  sort(s_sort,s_sort+n);

  for(int i=0;i<q;i++){
    string str;
    int a;

    cin >> str >> a;
    a--;

    if(str[0]=='A'){
      leader.insert(s[a]);
    }else if(str[0]=='R'){
      for(multiset<int>::iterator it = leader.begin();it!=leader.end();it++){
	if(*it == s[a]){
	  leader.erase(it);
	  break;
	}
      }
    }else{
      int ans = calc(a+1);
      if(ans <= 1000000000)
	cout << ans << endl;
      else
	cout << "NA" << endl;
    }
  }
  
  return 0;
}