import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
} Main public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    } main {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) String X = s.next(); X s.next() s.next s final int N = s.nextInt(); N s.nextInt() s.nextInt s List<String> pList = new ArrayList<String>(); pList new ArrayList<String>() for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        } int i = 0 ; int i = 0 ; i 0 i < N i N i++ i++ i {
            pList.add(s.next());
        } {
            pList.add(s.next());
        } pList.add(s.next()) pList.add pList s.next() s.next s if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        } pList.size() == 0 || !pList.contains(X) pList.size() == 0 pList.size() pList.size pList 0 !pList.contains(X) pList.contains(X) pList.contains pList X {
            System.out.println(X);
            return;
        } System.out.println(X) System.out.println System.out System System.out X return; int idx = 1; idx 1 while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        } true {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        } String minus = String.valueOf(Integer.parseInt(X) - idx); minus String.valueOf(Integer.parseInt(X) - idx) String.valueOf String Integer.parseInt(X) - idx Integer.parseInt(X) Integer.parseInt Integer X idx String plus = String.valueOf(Integer.parseInt(X) + idx); plus String.valueOf(Integer.parseInt(X) + idx) String.valueOf String Integer.parseInt(X) + idx Integer.parseInt(X) Integer.parseInt Integer X idx if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            } pList.contains(minus) && pList.contains(plus) pList.contains(minus) pList.contains pList minus pList.contains(plus) pList.contains pList plus {
                idx++;
                continue;
            } idx++ idx continue; if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            } !pList.contains(minus) && !pList.contains(plus) !pList.contains(minus) pList.contains(minus) pList.contains pList minus !pList.contains(plus) pList.contains(plus) pList.contains pList plus {
                System.out.println(minus);
                break;
            } System.out.println(minus) System.out.println System.out System System.out minus break; if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            } !pList.contains(minus) pList.contains(minus) pList.contains pList minus {
                System.out.println(minus);
                break;
            } System.out.println(minus) System.out.println System.out System System.out minus break; {
                System.out.println(plus);
                break;
            } System.out.println(plus) System.out.println System.out System System.out plus break; String[] args args public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
        String X = s.next();
        final int N = s.nextInt();
        List<String> pList = new ArrayList<String>();

        for (int i = 0 ; i < N ; i++) {
            pList.add(s.next());
        }

        if (pList.size() == 0 || !pList.contains(X)) {
            System.out.println(X);
            return;
        }

        int idx = 1;
        while (true) {
            String minus = String.valueOf(Integer.parseInt(X) - idx);
            String plus = String.valueOf(Integer.parseInt(X) + idx);
          
          if (pList.contains(minus) && pList.contains(plus)) {
                idx++;
                continue;
            }

            if (!pList.contains(minus) && !pList.contains(plus)) {
                System.out.println(minus);
                break;
            } else if (!pList.contains(minus)) {
                System.out.println(minus);
                break;
            } else {
                System.out.println(plus);
                break;
            }
        }
    }
}