import bisect def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 d = list(map(int, input[idx:idx + n])) idx += n x = int(input[idx]) y = int(input[idx + 1]) idx += 2 if x == 0 and y == 0: print(0) return M = abs(x) + abs(y) d_sorted = sorted(d) # Check 1 move pos = bisect.bisect_left(d_sorted, M) if pos < len(d_sorted) and d_sorted[pos] == M: print(1) return # Check 2 moves for d1 in d_sorted: low = max(M - d1, d1 - M) low = max(low, 1) # since d_i >= 1 high = d1 + M left = bisect.bisect_left(d_sorted, low) if left < len(d_sorted) and d_sorted[left] <= high: print(2) return print(-1) if __name__ == "__main__": main()