#include <stdio.h>
int find_pattern(int *mem, int n) {
// Write your pointer-based logic here
for(int i = 0; i<n; i++){
int *ptr1 = mem + i;
int *ptr2 = mem + 1 + i;
int *ptr3 = mem + 2 + i;
if ((*ptr2 == *ptr1 + 1) && (*ptr3 == *ptr2 + 1)){
return i;
}
}
return -1;
}
int main() {
int n, arr[100];
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int res = find_pattern(arr, n);
printf("%d", res);
return 0;
}