class C {
    static func solve() {
        let X = readLine()!.split(separator: " ").map { Int($0)! }.first!
        let ps = readLine()!.split(separator: " ").map { Int($0)! }.sorted()

        if ps.isEmpty {
            print(X)
            return
        }

        var temp = 500
        var diffTemp = 500
        ps.forEach { i in
            let diff = min(abs(X - i), diffTemp)
            if diff < diffTemp {
                temp = i
                diffTemp = diff
            }
        }
        var diff = 0
        while true {
            if !ps.contains(temp - diff) {
                print(temp - diff)
                break
            } else if !ps.contains(temp + diff) {
                print(temp + diff)
                break
            } else {
                diff += 1
            }
        }
    }
}

C.solve()
