def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 d_list = list(map(int, input[idx:idx + n])) idx += n x = int(input[idx]) y = int(input[idx + 1]) D = max(abs(x), abs(y)) if D == 0: print(0) return max_d = max(d_list) has_even = any(d % 2 == 0 for d in d_list) has_odd = any(d % 2 == 1 for d in d_list) mixed = has_even and has_odd all_even = has_even and not has_odd all_odd = has_odd and not has_even k_min = (D + max_d - 1) // max_d # ceil(D / max_d) # Check up to k_min + 4 to handle cases where the minimal k is near the boundary for k in range(k_min, k_min + 4 + 1): sum_max = k * max_d if sum_max < D: continue ok = False if mixed: ok = True elif all_even: ok = (D % 2 == 0) else: # all_odd ok = (k % 2 == D % 2) if ok: print(k) return print(-1) if __name__ == "__main__": main()