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


int main()
{
    int q,ope;
    long long num,L,R;
    std::cin>>q;
    std::set<long long> S;
    
    for(int i = 0; i < q; i++)
    {
        std::cin>>ope;
        if(ope==1){std::cin>>num; std::cout<<S.count(num)<<std::endl;}
        else if(ope==0){std::cin>>num; S.insert(num); std::cout<<S.size()<<std::endl;}
        else if(ope==2){std::cin>>num; S.erase(num);}
        else{
            std::cin>>L>>R;
            auto a = S.lower_bound(L);
            auto b = S.upper_bound(R);
            for(auto it = a; it!=b; it++){std::cout<<*it<<std::endl;}
        }
    } 
    return 0;
}

