package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var x, n int
	fmt.Fscan(r, &x, &n)

	if n == 0 {
		fmt.Fprintln(w, x)
		return
	}

	smallerList := NewSinglyLinkedList()
	biggerLiet := NewSinglyLinkedList()
	for i := 0; i < n; i++ {
		var p int
		fmt.Fscan(r, &p)
		if p <= x {
			smallerList.Add(p)
		} else {
			biggerLiet.Add(p)
		}
	}

	if !smallerList.Contains(x) {
		fmt.Fprintln(w, x)
		return
	}

	var result int

	for smallerRes, biggerRes := x-1, x+1; ; smallerRes, biggerRes = smallerRes-1, biggerRes+1 {
		if !smallerList.Contains(smallerRes) {
			result = smallerRes
			break
		}
		if !biggerLiet.Contains(biggerRes) {
			result = biggerRes
			break
		}
	}

	fmt.Fprintln(w, result)

}

/* --- singlylinkedlist --- */

type SllValue = interface{}

type SinglyLinkedList struct {
	first *sllElement
	last  *sllElement
	size  int
}

type sllElement struct {
	value SllValue
	next  *sllElement
}

func NewSinglyLinkedList(values ...SllValue) *SinglyLinkedList {
	sll := &SinglyLinkedList{}
	if len(values) > 0 {
		sll.Add(values...)
	}
	return sll
}

func (sll *SinglyLinkedList) Add(values ...SllValue) {
	for _, value := range values {
		newElement := &sllElement{value: value}
		if sll.size == 0 {
			sll.first = newElement
			sll.last = newElement
		} else {
			sll.last.next = newElement
			sll.last = newElement
		}
		sll.size++
	}
}

func (sll *SinglyLinkedList) Prepend(values ...SllValue) {
	for v := len(values) - 1; v >= 0; v-- {
		newElement := &sllElement{value: values[v], next: sll.first}
		sll.first = newElement
		if sll.size == 0 {
			sll.last = newElement
		}
		sll.size++
	}
}

func (sll *SinglyLinkedList) Get(index int) (SllValue, bool) {
	if !sll.withinRange(index) {
		return nil, false
	}

	element := sll.first
	for e := 0; e != index; e, element = e+1, element.next {
	}

	return element.value, true
}

func (sll *SinglyLinkedList) Remove(index int) {
	if !sll.withinRange(index) {
		return
	}

	if sll.size == 1 {
		sll.Clear()
		return
	}

	var beforeElement *sllElement
	element := sll.first
	for e := 0; e != index; e, element = e+1, element.next {
		beforeElement = element
	}

	if element == sll.first {
		sll.first = element.next
	}
	if element == sll.last {
		sll.last = beforeElement
	}
	if beforeElement != nil {
		beforeElement.next = element.next
	}

	element = nil
	sll.size--
}

func (sll *SinglyLinkedList) Contains(values ...SllValue) bool {
	if len(values) == 0 {
		return true
	}
	if sll.size == 0 {
		return false
	}
	for _, value := range values {
		found := false
		for element := sll.first; element != nil; element = element.next {
			if element.value == value {
				found = true
				break
			}
		}
		if !found {
			return false
		}
	}
	return true
}

func (sll *SinglyLinkedList) Values() []SllValue {
	values := make([]SllValue, sll.size, sll.size)
	for e, element := 0, sll.first; element != nil; e, element = e+1, element.next {
		values[e] = element.value
	}
	return values
}

func (sll *SinglyLinkedList) IndexOf(value SllValue) int {
	if sll.size == 0 {
		return -1
	}
	for index, element := range sll.Values() {
		if element == value {
			return index
		}
	}
	return -1
}

func (sll *SinglyLinkedList) Empty() bool {
	return sll.size == 0
}

func (sll *SinglyLinkedList) Size() int {
	return sll.size
}

func (sll *SinglyLinkedList) Clear() {
	sll.size = 0
	sll.first = nil
	sll.last = nil
}

func (sll *SinglyLinkedList) Sort(comparator func(a, b interface{}) int) {
	if sll.size < 2 {
		return
	}

	values := sll.Values()
	UtilSort(values, comparator)

	sll.Clear()
	sll.Add(values...)
}

func (sll *SinglyLinkedList) Swap(i, j int) {
	if sll.withinRange(i) && sll.withinRange(j) && i != j {
		var element1, element2 *sllElement
		for e, currentElement := 0, sll.first; element1 == nil || element2 == nil; e, currentElement = e+1, currentElement.next {
			switch e {
			case i:
				element1 = currentElement
			case j:
				element2 = currentElement
			}
		}
		element1.value, element2.value = element2.value, element1.value
	}
}

func (sll *SinglyLinkedList) Insert(index int, values ...interface{}) {

	if !sll.withinRange(index) {
		if index == sll.size {
			sll.Add(values...)
		}
		return
	}

	sll.size += len(values)

	var beforeElement *sllElement
	foundElement := sll.first
	for e := 0; e != index; e, foundElement = e+1, foundElement.next {
		beforeElement = foundElement
	}

	if foundElement == sll.first {
		oldNextElement := sll.first
		for i, value := range values {
			newElement := &sllElement{value: value}
			if i == 0 {
				sll.first = newElement
			} else {
				beforeElement.next = newElement
			}
			beforeElement = newElement
		}
		beforeElement.next = oldNextElement
	} else {
		oldNextElement := beforeElement.next
		for _, value := range values {
			newElement := &sllElement{value: value}
			beforeElement.next = newElement
			beforeElement = newElement
		}
		beforeElement.next = oldNextElement
	}
}

func (sll *SinglyLinkedList) Set(index int, value SllValue) {
	if !sll.withinRange(index) {
		if index == sll.size {
			sll.Add(value)
		}
		return
	}

	foundElement := sll.first
	for e := 0; e != index; {
		e, foundElement = e+1, foundElement.next
	}
	foundElement.value = value
}

func (sll *SinglyLinkedList) String() string {
	str := "SinglyLinkedList\n"
	values := []string{}
	for element := sll.first; element != nil; element = element.next {
		values = append(values, fmt.Sprintf("%v", element.value))
	}
	str += strings.Join(values, ", ")
	return str
}

func (sll *SinglyLinkedList) withinRange(index int) bool {
	return index >= 0 && index < sll.size
}

/*--- sort ---*/

func UtilSort(values []interface{}, comparator func(a, b interface{}) int) {
	sort.Sort(utilSortable{values: values, comparator: comparator})
}

type utilSortable struct {
	values     []interface{}
	comparator func(a, b interface{}) int
}

func (s utilSortable) Len() int {
	return len(s.values)
}
func (s utilSortable) Swap(i, j int) {
	s.values[i], s.values[j] = s.values[j], s.values[i]
}
func (s utilSortable) Less(i, j int) bool {
	return s.comparator(s.values[i], s.values[j]) < 0
}

/* --- singlylinkedlist iterator --- */

type SllIterator struct {
	list    *SinglyLinkedList
	index   int
	element *sllElement
}

func (list *SinglyLinkedList) Iterator() SllIterator {
	return SllIterator{list: list, index: -1, element: nil}
}

func (iterator *SllIterator) Next() bool {
	if iterator.index < iterator.list.size {
		iterator.index++
	}
	if !iterator.list.withinRange(iterator.index) {
		iterator.element = nil
		return false
	}
	if iterator.index == 0 {
		iterator.element = iterator.list.first
	} else {
		iterator.element = iterator.element.next
	}
	return true
}

func (iterator *SllIterator) Value() interface{} {
	return iterator.element.value
}

func (iterator *SllIterator) Index() int {
	return iterator.index
}

func (iterator *SllIterator) Begin() {
	iterator.index = -1
	iterator.element = nil
}

func (iterator *SllIterator) First() bool {
	iterator.Begin()
	return iterator.Next()
}


Measured memory_bytes: 1844