using System; using System.Linq; public class Program { static void Main() { string s = Console.ReadLine(); int N = int.Parse(s); s = Console.ReadLine(); var t = s.Split(' '); var D = new long[N]; for (int i = 0; i < N; ++i) { D[i] = long.Parse(t[i]); } Array.Sort(D); s = Console.ReadLine(); t = s.Split(' '); long x = long.Parse(t[0]); long y = long.Parse(t[1]); long X = Math.Abs(x + y); long Y = Math.Abs(x - y); long M = Math.Max(X, Y); if (x == 0 && y == 0) { Console.WriteLine(-1); return; } if (D.Contains(M)) { Console.WriteLine(1); return; } for (int i = 0; i < N; ++i) { int hi = i; int lo = 0; while (hi - lo > 1) { int mid = (hi + lo) / 2; if (D[i] - D[mid] >= M) { lo = mid; } else { hi = mid; } } if (lo == i) { lo -= 1; } if (lo >= 0 && D[i] - D[lo] <= M && M <= D[i] + D[lo]) { Console.WriteLine(2); return; } } for (int i = 0; i < N-1; ++i) { int hi = i + 1; if (hi < N && D[hi] - D[i] <= M && M <= D[i] + D[hi]) { Console.WriteLine(2); return; } } Console.WriteLine(-1); } }