import java.util.*;
import java.lang.Math;

public class Main {
//public static final int MIN_VALUE
//public static final int MAX_VALUE

/**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
}

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

}

}; import java.util.*; util.* java import java.lang.Math; Math java.lang public class Main {
//public static final int MIN_VALUE
//public static final int MAX_VALUE

/**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
}

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

}

} Main /**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
} indexOf {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
} int ret = -1; ret -1 1 int l l m m r; r l = 0 l 0 r = a.length - 1 r a.length - 1 a.length a a.length 1 while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    } l <= r l r {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    } m = (l+r) / 2 m (l+r) / 2 (l+r) l r 2 if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        } a[m] == x a[m] a m x {
            ret = m;
            break;
        } ret = m ret m break; if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        } a[m] < x a[m] a m x {
            l = m + 1;
        } l = m + 1 l m + 1 m 1 {
            r = m - 1;
        } r = m - 1 r m - 1 m 1 return ret; ret int[] a a int x x public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

} main {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x x n; n int pos pos cpos; cpos int lcand lcand rcand; rcand boolean found; found x = scan.nextInt() x scan.nextInt() scan.nextInt scan n = scan.nextInt() n scan.nextInt() scan.nextInt scan if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    } n == 0 n 0 {
        System.out.println(x);
        scan.close();
        return;
    } System.out.println(x) System.out.println System.out System System.out x scan.close() scan.close scan return; int[] p = new int[n]; p new int[n] n for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } int i=0; int i=0; i 0 i<n i n i++ i++ i {
        p[i] = scan.nextInt();
    } {
        p[i] = scan.nextInt();
    } p[i] = scan.nextInt() p[i] p i scan.nextInt() scan.nextInt scan Arrays.sort(p) Arrays.sort Arrays p cpos = indexOf(p,x) cpos indexOf(p,x) indexOf p x if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    } cpos != -1 cpos -1 1 {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } pos = 0 pos 0 while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        } true {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        } pos++ pos found = false found false lcand = Integer.MIN_VALUE lcand Integer.MIN_VALUE Integer Integer.MIN_VALUE rcand = Integer.MAX_VALUE rcand Integer.MAX_VALUE Integer Integer.MAX_VALUE if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            } (cpos - pos) < 0 (cpos - pos) cpos pos 0 {
                //範囲外
                lcand = x - pos;
                found = true;
            } lcand = x - pos lcand x - pos x pos found = true found true {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            } if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                } p[cpos-pos] == (x - pos) p[cpos-pos] p cpos-pos cpos pos (x - pos) x pos {
                } {
                    lcand = x-pos;
                    found = true;
                } lcand = x-pos lcand x-pos x pos found = true found true if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } (cpos + pos) >= n (cpos + pos) cpos pos n {
                // 範囲外
                rcand = x + pos;
                found = true;
            } rcand = x + pos rcand x + pos x pos found = true found true {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                } p[cpos+pos] == (x + pos) p[cpos+pos] p cpos+pos cpos pos (x + pos) x pos {
                } {
                    rcand = x+pos;
                    found = true;
                } rcand = x+pos rcand x+pos x pos found = true found true if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            } found {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            } if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                } Math.abs(x-rcand) < Math.abs(x-lcand) Math.abs(x-rcand) Math.abs Math x-rcand x rcand Math.abs(x-lcand) Math.abs Math x-lcand x lcand {
                    System.out.println(rcand);
                } System.out.println(rcand) System.out.println System.out System System.out rcand {
                    System.out.println(lcand);
                } System.out.println(lcand) System.out.println System.out System System.out lcand break; {
        
//        System.out.println("not found");
        System.out.println(x);
    } System.out.println(x) System.out.println System.out System System.out x scan.close() scan.close scan String[] args args public class Main {
//public static final int MIN_VALUE
//public static final int MAX_VALUE

/**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
}

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

}

} public class Main {
//public static final int MIN_VALUE
//public static final int MAX_VALUE

/**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
}

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

}

} Main
import java.util.*;
import java.lang.Math;

public class Main {
//public static final int MIN_VALUE
//public static final int MAX_VALUE

/**
 * ソート済みの配列を2分探索し、indexを返す。
 * 見つからない場合は-1を返す
 * @param a
 * @param x
 * @return
 */
public static int indexOf(int[] a, int x) {
    int ret = -1;

    int l,m,r;
    l = 0;r = a.length - 1; 

    while(l <= r) {
        m = (l+r) / 2;
        if(a[m] == x) {
            ret = m;
            break;
        } else if(a[m] < x) {
            l = m + 1;
        } else {
            r = m - 1;
        }
    }

    return ret;
}

public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int x,n;
    int pos,cpos;
    int lcand,rcand;
    boolean found;

    x = scan.nextInt();
    n = scan.nextInt();

    if(n == 0) {
        System.out.println(x);
        scan.close();
        return;
    }

    int[] p = new int[n];
    for(int i=0;i<n;i++) {
        p[i] = scan.nextInt();
    } 

    Arrays.sort(p);

//    System.out.println(x);
//    for(int i=0;i<n;i++) {
//        System.out.println(p[i]);
//    }

    cpos = indexOf(p,x);
    if(cpos != -1) {
        // 見つかった場合、そこから左右に伸びていく
        pos = 0;
        
        while(true) {
            pos++;
            found = false;
            lcand = Integer.MIN_VALUE;
            rcand = Integer.MAX_VALUE;
            //左
            if((cpos - pos) < 0) {
                //範囲外
                lcand = x - pos;
                found = true;
            } else {
                if(p[cpos-pos] == (x - pos)) {
                } else {
                    lcand = x-pos;
                    found = true;
                }
            }

            //右
            if((cpos + pos) >= n) {
                // 範囲外
                rcand = x + pos;
                found = true;
            } else {
                if(p[cpos+pos] == (x + pos)) {
                } else {
                    rcand = x+pos;
                    found = true;
                }
            } 
            if(found) {
                if(Math.abs(x-rcand) < Math.abs(x-lcand)) {
                    System.out.println(rcand);
                } else {
                    System.out.println(lcand);
                }
                break;
            }
        }

    } else {
        
//        System.out.println("not found");
        System.out.println(x);
    }

    scan.close();

}

};
