//テンプレート //Visual Studio用 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; template bool chmin(T& a, T b) { return a > b ? a = b, true : false; } template bool chmax(T& a, T b) { return a < b ? a = b, true : false; } templateistream& operator>>(istream& is, vector& v) { for (auto& e : v)is >> e; return is; } templateostream& operator<<(ostream& os, vector& v) { for (auto& e : v)os << e << " "; return os; } using ll = long long; using ull = unsigned long long; using uint = unsigned int; template struct Edge { int to; T weight; Edge(int t, T w) :to(t), weight(w) {} bool operator==(Edge e) { return this->to == e.to and this->weight == e.weight; } bool operator<(Edge e) { if (this->to < e.to) { return this->weight <= e.weight; } else return false; } }; template class Graph { using graph_ = vector>>; graph_ g; public: Graph(int n) :g(n) {} graph_::iterator begin() { return g.begin(); } graph_::const_iterator begin() const { return g.begin(); } graph_::iterator end() { return g.end(); } graph_::const_iterator end() const { return g.end(); } vector>& operator [](int v) { return g[v]; } const graph_& data() { return g; } void add(int u, int v, T w = 1) { g[u].emplace_back(Edge{ v, w }); } void wadd(int u, int v, T w = 1) { add(u, v, w); add(v, u, w); } }; //Atcoder Library /**/ #include using namespace atcoder; //using mint = modint998244353; using mint = modint1000000007; //using mint = dynamic_modint<0>; //using mint = modint; //mint::set_mod(); istream& operator>>(istream& is, mint& x) { ll r; cin >> r; x = r; return is; } ostream& operator<<(ostream& os, mint& x) { cout << x.val(); return os; } /**/ #define SHOW(n) cerr << #n << " = " << n << endl; /* ここまでテンプレート */ int main() { int n; cin >> n; vector a(1000001); for (int i = 0; i < n; ++i) { int x; cin >> x; a[x]++; } for (int i = 100000; i >= 0; --i) { if (a[i] > 0) { --a[i]; break; } } for (int i = 0; i <= 100000; ++i) { if (a[i] <= 1) { a[i]++; break; } } for (int i = 0; i <= 100000; ++i) { if (a[i] <= 1) { cout << i << endl; break; } } return 0; }