#include <iostream>
#include <algorithm>
using namespace std;

#define UpdMin(x, y) x = min(x, y)

const int MAX_N = 200010;
bool Flag[MAX_N];
int N;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++)
	{
		int x;
		cin >> x;
		Flag[x] = true;
		while (Flag[ans])
			ans++;
		cout << ans << endl;
	}
	return 0;
}

#include <bits/stdc++.h>

template <typename T>
T next() {
    T temp; std::cin >> temp;
    return temp;
}

template <>
int next() {
    int temp; scanf("%d", &temp);
    return temp;
}
template <>
long long next() {
    long long temp; scanf("%lld", &temp);
    return temp;
}
template <>
double next() {
    double temp; scanf("%lf", &temp);
    return temp;
}
template <>
float next() {
    float temp; scanf("%f", &temp);
    return temp;
}

template <typename T1, typename T2>
std::pair<T1, T2> next() {
    std::pair<T1, T2> temp;
    temp.first = next<T1>();
    temp.second = next<T2>();
    return temp;
}

template <typename T>
std::vector<T> next(int n) {
    std::vector<T> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T>();
    return temp;
}

template <typename T1, typename T2>
std::vector<std::pair<T1, T2>> next(int n) {
    std::vector<std::pair<T1, T2>> temp(n);
    for(int i = 0; i < n; i++)
        temp[i] = next<T1, T2>();
    return temp;
}

template <typename T>
void print(const T &x, char endc = '\n') {
    std::cout << x << endc;
    return;
}
void print(const int &x, char endc = '\n') {
    printf("%d%c", x, endc);
    return;
}
void print(const long long &x, char endc = '\n') {
    printf("%lld%c", x, endc);
    return;
}
void print(const size_t &x, char endc = '\n') {
    printf("%zu%c", x, endc);
    return;
}
void print(const float &x, char endc = '\n') {
    printf("%f%c", x, endc);
    return;
}
void print(const double &x, char endc = '\n') {
    printf("%lf%c", x, endc);
    return;
}

template<typename T1, typename T2>
void print(const std::pair<T1, T2> &p, char sepc = ' ', char endc = '\n') {
    print(p.first, sepc);
    print(p.second, endc);
    return;
}

template<typename T>
void print(const std::vector<T> &v, char sepc = ' ', char endc = '\n') {
    for(const T &e : v) print(e, sepc);
    printf("%c", endc);
    return;
}




template<typename T>
class SparseGraph {
    struct Node {
        std::vector<std::pair<int, T>> adj;
        T value;
    };

private:
    std::vector<Node> nodes;
    int nodeSize;
    int edgeSize = 0;

public:
    SparseGraph(int n) {
        nodes.resize(n);
        nodeSize = n;
    }

    SparseGraph(const std::vector<T> &values) {
        int n = values.size();
        nodes.resize(n);
        nodeSize = n;
        for(int i = 0; i < n; i++)
            nodes[i].value = values[i];
    }

    void addEdge(int u, int v, const T &edgeVal = 0) {
        nodes[u].adj.push_back({v, edgeVal});
        edgeSize++;
    }

    const int &getNodeSize() const {
        return nodeSize;
    }

    const int &getEdgeSize() const {
        return edgeSize;
    }

    const T &valueOf(int here) const {
        return nodes[here].value;
    }

    const std::vector<std::pair<int, T>> &adjOf(int here) const {
        return nodes[here].adj;
    }
};



using namespace std;



void eachTC() {
    int A = next<int>(), B = next<int>();
    int solid = A+B, fat = B;

    int res;
    if(solid >= 15 && fat >= 8)
        res = 1;
    else if(solid >= 10  && fat >= 3)
        res = 2;
    else if(solid >= 3)
        res = 3;
    else
        res = 4;
    
    print(res);
}

int main() {
    constexpr bool multipleTC = false;
    int T = multipleTC ? next<int>() : 1;
    while(T--) eachTC();

    return 0;
}
