#include <stdio.h>
#include <string.h>

int main(void) {
	int n;
	int d;
	char suuretu[1024];
	int i;
	char current[16];
	if (scanf("%d", &n) != 1) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%d", &d) != 1) return 1;
		suuretu[i] = d + '0';
	}
	suuretu[n] = '\0';
	for (i = 0;; i++) {
		sprintf(current, "%d", i);
		if (strstr(suuretu, current) == NULL) {
			printf("%d\n", i);
			return 0;
		}
	}
}