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