#include <stdio.h>


void main()
{
    int a[100], n, target, temp1, temp2, index;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)  
        scanf("%d", &a[i]);  // Initializing array

    scanf("%d", &target);  // Initializing target

    temp2 = INT_MAX();  // Setting temp2 to the highest int value for the first iteration to be successful

    for (int i = 0; i < n; i++)
    {
        temp1 = a[i] - target;

        if (temp1 < 0)
            temp1 = temp1 * -1;  // Converting the difference to a positive number for comparison

        if (temp1 < temp2)
        {
            temp2 = temp1;  // Storing the least difference through each iteration
            index = i;  // Storing the index
        }
    }

    printf("%d", a[index]);
}