#include <stdio.h>
int find_pattern(int *mem, int n) {
// Write your pointer-based logic here
int i, *ptr;
// to find a patch of three consecutive integers,
// no use going beyond (n-3)
for (i=0, ptr=mem; i < (n-3); i++) {
if (((*ptr) == (*(ptr+1)-1)) && ((*ptr) == (*(ptr+2)-2))) {
return i;
}
else {
ptr++;
}
}
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;
}