import java.util.*;
import java.util.stream.Collectors;

public class Minimax {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        List<Integer> nums = new ArrayList<>(n);
        for (int i = 0; i < n; i++) {
            nums.add(in.nextInt());
        }
        Collections.sort(nums);
        int p = in.nextInt();
        int q = in.nextInt();
        //nums = nums.stream().filter(x -> (x >= p) && (x <= q)).collect(Collectors.toList());
        Collection<PossibleSolution> possibleSolutions = new ArrayList<>();
        //nums.add(0, p);
        //nums.add(nums.size(), q);
        for (int i = 0; i < nums.size() - 1; i++) {
            int diff = nums.get(i + 1) - nums.get(i);
            possibleSolutions.add(new PossibleSolution(diff/2, (diff / 2) + nums.get(i)));
        }
        nums = nums.stream().filter(x -> (x >= p) && (x <= q)).collect(Collectors.toList());
        possibleSolutions.add(new PossibleSolution(Math.abs(p - nums.stream().min(Integer::compareTo).get()), p));
        possibleSolutions.add(new PossibleSolution(Math.abs(q - nums.stream().max(Integer::compareTo).get()), q));
        possibleSolutions.stream().filter(x -> x.isInRange(p, q)).max(PossibleSolution::compareTo).get().printVal();
    }

    private static void solveDirectly(List<Integer> nums, int p, int q) {
        int minDiff = Integer.MIN_VALUE;
        int minVal = 0;
        for (int m = p; m <= q; m++) {
            int finalM = m;
            int diff = nums.stream().map(x -> Math.abs(finalM - x)).reduce(Integer::compareTo).orElseThrow(IllegalStateException::new);
            if (diff > minDiff) {
                minDiff = diff;
                minVal = m;
            }
        }
        System.out.print(minVal);
    }
}

class PossibleSolution implements Comparable<PossibleSolution> {
    private final int diff;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PossibleSolution that = (PossibleSolution) o;

        if (diff != that.diff) return false;
        return val == that.val;
    }

    @Override
    public int hashCode() {
        int result = diff;
        result = 31 * result + val;
        return result;
    }

    private final int val;

    public PossibleSolution(int diff, int val) {
        this.diff = diff;
        this.val = val;
    }

    @Override
    public int compareTo(PossibleSolution o) {
        int diffComp = Integer.compare(this.diff, o.diff);
        return diffComp != 0 ? diffComp : Integer.compare(this.val, o.val);
    }

    public void printVal() {
        System.out.println(val);
    }

    public boolean isInRange(int p, int q) {
        return this.val >= p && this.val <= q;
    }
}

@@ -16,44 +16,8 @@
 l.*;
-%0Aimport java.util.stream.Collectors;
 %0A%0Apu
@@ -781,17 +781,19 @@
 ion(diff
-/
+ / 
 2, (diff
@@ -829,24 +829,26 @@
   %7D%0A        
+//
 nums = nums.
@@ -975,64 +975,35 @@
 ion(
-Math.abs(p - nums.stream().min(Integer::compareTo).get()
+diffForNumClosestTo(nums, p
 ), p
@@ -1061,68 +1061,102 @@
 ion(
-Math.abs(q - nums.stream().max(Integer::compareTo).get()), q
+diffForNumClosestTo(nums, q), q));%0A        possibleSolutions.forEach(x -%3E System.err.println(x
 ));%0A
@@ -1271,32 +1271,201 @@
 ntVal();%0A    %7D%0A%0A
+    private static int diffForNumClosestTo(Collection%3CInteger%3E nums, int p) %7B%0A        return nums.stream().map(x -%3E Math.abs(x-p)).min(Integer::compareTo).get();%0A    %7D%0A%0A
     private stat
@@ -2744,16 +2744,17 @@
  return 
+(
 diffComp
@@ -2758,16 +2758,17 @@
 omp != 0
+)
  ? diffC
@@ -2789,24 +2789,31 @@
 compare(
+o.val, 
 this.val
 , o.val)
@@ -2808,16 +2808,173 @@
 .val
-, o.val)
+);%0A    %7D%0A%0A    @Override%0A    public String toString() %7B%0A        return %22PossibleSolution%7B%22 +%0A            %22diff=%22 + diff +%0A            %22, val=%22 + val +%0A            '%7D'
 ;%0A  
@@ -3107,16 +3107,17 @@
  return 
+(
 this.val
@@ -3121,20 +3121,22 @@
 val %3E= p
+)
  && 
+(
 this.val
@@ -3140,16 +3140,17 @@
 val %3C= q
+)
 ;%0A    %7D%0A

fix minimax