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 int[N]; for (int i = 0; i < N; ++i) { D[i] = int.Parse(t[i]); } Array.Sort(D); s = Console.ReadLine(); t = s.Split(' '); int x = int.Parse(t[0]); int y = int.Parse(t[1]); int X = Math.Abs(x + y); int Y = Math.Abs(x - y); int M = Math.Max(X, Y); if (D.Contains(M)) { Console.WriteLine(1); return; } for (int i = 0; i < N; ++i) { int hi = N; int lo = 0; while (hi - lo > 1) { int mid = (hi + lo) / 2; if (D[mid] <= M + D[i]) { lo = mid; } else { hi = mid; } } if (lo == i) { lo += 1; } if (lo < N && D[lo] <= M + D[i] && D[lo] >= M - D[i]) { Console.WriteLine(2); return; } } Console.WriteLine(-1); } }