#include <stdio.h>
#include <stdlib.h>

int main() {
  int x, count;
  scanf("%d%d", &x, &count);
  int array[count];
  for (int i = 0; i < count; i++) {
    scanf("%d", &array[i]);
  }
  int array2[100 - count];
  int check = 0;
  int m = 0;
  for (int j = 0; j <= 100 - count; j++) {
    for (int k = 0; k < count; k++) {
      if (j != array[k]) {
        check++;
      }
    }
    if (check == count) {
      array2[m] = j;
      m++;
    }
    check = 0;
  }
  int tmp = abs(x);
  int tmp2 = 0;
  int index = 0;
  x = abs(x);
  for (int l = 0; l <= 100 - count; l++) {
    tmp2 = abs(array2[l] - x);
    if (tmp > tmp2) {
      tmp = tmp2;
      index = l;
    }
  }
  if (tmp > abs(-1 - x)) {
    index = -1;
  }
  printf("%d\n", index);
  return 0;
}