using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var d = NList; var c = NList; WriteLine(Game(n, d, Math.Abs(c[0]) + Math.Abs(c[1]))); } static int Game(int n, int[] d, long x) { if (x == 0) { return 0; } var emax = -1; var omax = -1; var elist = new List(); var olist = new List(); foreach (var di in d) { if (x == di) { return 1; } if (di % 2 == 0) { emax = Math.Max(emax, di * 2); elist.Add(di); } else { omax = Math.Max(omax, di * 2); olist.Add(di); } } if (x % 2 == 0) return x <= emax || x <= omax ? 2 : -1; else { if (elist.Count == 0 || olist.Count == 0) { return -1; } elist.Sort(); olist.Sort(); foreach (var e in elist) { var opos = Math.Max(LowerBound(0, e, olist), LowerBound(0, x - e, olist)); if (opos < olist.Count && olist[opos] <= x + e) { return 2; } } foreach (var o in olist) { var epos = Math.Max(LowerBound(0, o, elist), LowerBound(0, x - o, elist)); if (epos < elist.Count && elist[epos] <= x + o) { return 2; } } return -1; } } static int LowerBound(int left, long min, IList list) { if (list[left] >= min) return left; var ng = left; var ok = list.Count; while (ok - ng > 1) { var mid = (ng + ok) / 2; if (list[mid] < min) ng = mid; else ok = mid; } return ok; } }