#include <bits/stdc++.h>
using std::min;
const int MAXN = 1e5 + 10;
int n, N;
bool f[MAXN];
int a[MAXN * 4];
inline void push_up(int u) { a[u] = min(a[(u << 1)], a[(u << 1 | 1)]); }
void assign(int u, int l, int r, int p, int v) {
  if (l == r)
    a[u] = v;
  else {
    register int mid = (l + r) / 2;
    if (p <= mid)
      assign((u << 1), l, mid, p, v);
    else
      assign((u << 1 | 1), mid + 1, r, p, v);
    push_up(u);
  }
}
int ask(int u, int l, int r, int ql, int qr) {
  if (ql <= l && r <= qr)
    return a[u];
  else {
    register int mid = (l + r) / 2, ret = 0x3f3f3f3f;
    if (ql <= mid) ret = min(ret, ask((u << 1), l, mid, ql, qr));
    if (mid + 1 <= qr) ret = min(ret, ask((u << 1 | 1), mid + 1, r, ql, qr));
    return ret;
  }
}
int main() {
  scanf("%d", &n);
  N = n + 1;
  for (register int i = 1, x; i <= n * 2; ++i) {
    scanf("%d", &x);
    if (x != 1) {
      f[1] = 1;
      if (ask(1, 1, N, x, x) < ask(1, 1, N, 1, x - 1)) f[x] = 1;
    }
    assign(1, 1, N, x, i);
  }
  for (register int i = 2; i <= n + 1; ++i)
    if (ask(1, 1, N, i, i) < ask(1, 1, N, 1, i - 1)) f[i] = 1;
  for (register int i = 1; i <= n + 2; ++i)
    if (!f[i]) {
      printf("%d\n", i);
      break;
    }
  return 0;
}
