#include <bits/stdc++.h>
using namespace std;
//typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
 
int main(){
	int q,c,x;
	cin >> q;
	set<int> se;
	while(q--){
		cin >> c >> x;
		if(c==1){
			cout << se.count(x) << endl;
		}else if(c==0){
			se.insert(x);
			cout << se.size() << endl;
		}else if(c==2){
			se.erase(x);
		}else if(c==3){
			int L = x;
			int R; cin >> R;
			auto it = se.lower_bound(L);
			auto end = se.upper_bound(R);
			for(;it!=end;it++){
				cout << (*it) << endl;
			}
		}
	}
}
