#include <stdio.h>
int find_pattern(int *mem, int n) {
int last = *mem++;
int consec = 0;
int i;
for(i = 1; i < n; i++){
if(*mem == (last + 1)){
consec++;
if(consec == 2){
return (i - consec);
}
}else{
consec = 0;
}
last = *mem++;
}
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;
}