#include<iostream>
#include<memory>
#include<cstdint>
#include<random>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;

template<typename T> 
class SplayTree_Set{
private:
    template<typename U = T>
    class Node{
    public:
        Node<U>* par;
        Node<U>* left; 
        Node<U>* right;
        T value;
        Node() : par(nullptr), left(nullptr), right(nullptr){}
    };
private:
    void rotate_right(Node<T>* node){
        Node<T>* child = node->left;
        Node<T>* par = node->par;
        if(root == node) root = child;
        else {
            if(par->left == node) par->left = child;
            else par->right = child;
        }
        child->par = par;
        node->left = child->right;
        if(child->right) child->right->par = node;
        child->right = node;
        node->par = child;
    }
    void rotate_left(Node<T>* node){
        Node<T>* child = node->right;
        Node<T>* par = node->par;
        if(root == node) root = child;
        else {
            if(par->left == node) par->left = child;
            else par->right = child;
        }
        child->par = par;
        node->right = child->left;
        if(child->left) child->left->par = node;
        child->left = node;
        node->par = child;
    }
    void zig(Node<T>* node){
        if(node->par->left == node) rotate_right(node->par);
        else rotate_left(node->par);
    }
    void zig_zag(Node<T>* node){
        if(node->par->left == node){
            rotate_right(node->par);
            rotate_left(node->par);
        } else {
            rotate_left(node->par);
            rotate_right(node->par);            
        }
    }
    void zig_zig(Node<T>* node){
        if(node->par->left == node){
            rotate_right(node->par->par);
            rotate_right(node->par);
        } else {
            rotate_left(node->par->par);
            rotate_left(node->par);
        }
    }
    Node<T>* make_node(T val, Node<T>* par){
        Node<T>* node = new Node<T>();
        node->value = val;
        node->par = par;
        return node;
    }
private:
    void splay(Node<T>* node){
        while(node->par) {
            Node<T>* par = node->par;
            if(par == root) zig(node);
            else{
                bool zigzag = false;
                Node<T>* gra = par->par;
                if(gra->left == par) zigzag ^= 1;
                if(par->left == node) zigzag ^= 1;
                if(zigzag) zig_zag(node);
                else zig_zig(node);
            }
        }
    }
    
public:
    Node<T>* root;
    SplayTree_Set() : root(nullptr) {}
    void insert(T val){
        Node<T>* leaf = root;
        bool end = false;
        if(root == nullptr){
            root = make_node(val, nullptr);
            return;
        }
        while(!end){
            if(leaf->value == val) return;
            if(leaf->value < val) {
                if(leaf->right == nullptr) end = true;
                else leaf = leaf->right;
            }
            else {
                if(leaf->left == nullptr) end = true;
                else leaf = leaf->left;
            }
        }

        Node<T>* node = make_node(val, leaf);
        if(leaf->value < val && !leaf->right) leaf->right = node;
        else if(leaf->value >= val && !leaf->left) leaf->left = node;
        splay(node);
    }
    bool contains(T val){
        Node<T>* node = root;
        while(1){
            if(node->value == val){
                splay(node);
                return true;
            } 
            else if(node->value < val && node->right) node = node->right;
            else if(node->value >= val && node->left) node = node->left; 
            else {splay(node); return false;}
        }
    }
    void remove(T val);
    size_t find(T val);
    T lower_bound(T val);
    T upper_bound(T val);
    void test(Node<T>* node = nullptr){
        if(!node) node = root;
        cout << "value: "<<node->value << endl;
        if(node->left) test(node->left);
        //if(node->right) test(node->right);
    }
};

int main(){
    using Int = int_fast64_t;
    Int N, a, Q, k;
    cin >> N;
    SplayTree_Set<Int> splayTree;
    for(int i = 0; i < N; i++){
        cin >> a;
        splayTree.insert(a);
    } 
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> k;
        cout << splayTree.contains(k) << endl;
    }
}


Measured memory_bytes: 7768