#include <stdio.h>
int find_pattern(int *mem, int n) {
// Write your pointer-based logic here
int chain = 0;
for (int i = 0; i < n-1; i++) {
int val_1 = *(mem+i);
int val_2 = *(mem+i+1);
if ((val_1 + 1) == val_2) {
chain++;
} else {
chain = 0;
}
if (2 == chain)
return i-1;
}
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;
}