Tattah's youngest brother, Tuftuf, is new to programming.Since his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in Gava.Today, Tuftuf was introduced to Gava's unsigned integer datatypes. Gava has n unsigned integer datatypes of sizes (in bits) a1, a2, ... an. The i-th datatype have size ai bits, so it can represent every integer between 0 and 2ai - 1 inclusive. Tuftuf is thinking of learning a better programming language. If there exists an integer x, such that x fits in some type i (in ai bits) and x·x does not fit in some other type j (in aj bits) where ai < aj, then Tuftuf will stop using Gava.Your task is to determine Tuftuf's destiny.

The first line contains integer n (2 ≤ n ≤ 105) — the number of Gava's unsigned integer datatypes' sizes. The second line contains a single-space-separated list of n integers (1 ≤ ai ≤ 109) — sizes of datatypes in bits. Some datatypes may have equal sizes.

Print "YES" if Tuftuf will stop using Gava, and "NO" otherwise.

NoteIn the second example, x = 7 (1112) fits in 3 bits, but x2 = 49 (1100012) does not fit in 4 bits.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

namespace Codeforces
{
    internal class Program
    {
        private const string TEST = "A1";

        private static void Solve()
        {
            var n = ReadInt();
            var a = new List<int>(ReadIntArray());
            a.Sort();
            for (int i = a.Count - 1; i >= 1; i--)
            {
                if(a[i] != a[i - 1] && a[i] < 2 * a[i-1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", TEST)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static int[] ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
            return input;
        }

        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static int ReadNextInt(string[] input, int index)
        {
            return Int32.Parse(input[index]);
        }

        #endregion
    }
}

using System;
using System.IO;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApplication1
{
    class Program
    {
        static class Scanner
        {
            static IEnumerator<string> tokens;
            static Scanner()
            {
                tokens = Enumerable.Range(Int32.MinValue, Int32.MaxValue).
                    Select(s => Console.ReadLine()).
                    TakeWhile(s => s != null).
                    SelectMany(s => s.Split(new char[] { ' ', '\r', '\n', '\t' }, StringSplitOptions.RemoveEmptyEntries)).
                    Concat(Enumerable.Repeat(0, 1).Select(_ => (string)null)).
                    GetEnumerator();
            }
            public static string nextToken()
            {
                tokens.MoveNext();
                return tokens.Current;
            }
        }

        int nextInt()
        {
            return int.Parse(Scanner.nextToken());
        }

        long nextLong()
        {
            return long.Parse(Scanner.nextToken());
        }

        double nextDouble()
        {
            return double.Parse(Scanner.nextToken());
        }

        bool isPalindrome(string str)
        {
            int x = 0, y = str.Length - 1;
            while (y > x)
            {
                if (str[x] != str[y]) return false;
                x++; y--;
            }
            return true;
        }

        void Solve()
        {
            int n = nextInt();
            int[] a=new int[n];
            for(int i=0;i<n;i++)a[i]=nextInt();
            a = a.OrderBy(c => c).Distinct().ToArray();
            for (int i = 1; i < a.Length; i++)
            {
                if (a[i - 1] * 2 > a[i])
                {
                    Console.Write("YES");
                    return;
                }
            }
            Console.Write("NO");
        }

        static void Main(string[] args)
        {
#if MY_SUPER_PUPER_ONLINE_JUDGE
            string dir = Directory.GetCurrentDirectory();
            dir = Directory.GetParent(dir).FullName;
            dir = Directory.GetParent(dir).FullName;
            Console.SetIn(new StreamReader(dir + "\\input.txt"));
            Console.SetOut(new StreamWriter(dir + "\\output.txt"));
#endif
            Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            new Program().Solve();
#if MY_SUPER_PUPER_ONLINE_JUDGE
            Console.In.Close();
            Console.Out.Close();
#endif
        }
    }
}

using System;
using System.Collections;
using System.Text;

namespace CodeForces_83
{
    class prob_b
    {

        static void Main()
        {
            int n = Int32.Parse (Console.ReadLine());
            int i;
            string[] val = Console.ReadLine().Split(" ".ToCharArray());
            int[] n1 = new int[n];

            for (i = 0; i < n; ++i)
                n1[i] = Int32.Parse(val[i]);
            Array.Sort(n1);

            for (i = 1; i < n; ++i)
            {
                if (n1[i] > n1[i - 1] && n1[i] < 2 * n1[i - 1]) break;
            }
            if (i == n)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Task
{
    #region MyIo

    class MyIo : IDisposable
    {
        TextReader inputStream;
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();
        }
    }
    #endregion

    class Program
    {
        #region Program
        MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        static void Main(string[] args)
        {
#if  LOCAL_TEST
            using (MyIo io = new MyIo(new StreamReader("input.txt")))
#else
            using (MyIo io = new MyIo(System.Console.In))
#endif

            {
                new Program(io)
                    .Solve();

#if  LOCAL_TEST
                Console.ReadLine();
#endif
            }
        }

        #endregion

        void Solve()
        {
            int n = io.NextInt();

            long[] nums = new long[n];

            for (int i = 0; i < n; i++)
                nums[i] = io.NextLong();

            Array.Sort(nums);

            for (int i = 0; i < n - 1; i++)
            {
                if (nums[i] < nums[i + 1] && nums[i + 1] < (nums[i] << 1))
                {
                    io.Print("YES");
                    return;
                }
            }

            io.Print("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace b1cs
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] ss = Console.ReadLine().Split();
            List<int> a = new List<int>();
            for (int i = 0; i < n; i++)
            {
                a.Add(int.Parse(ss[i]));
            }
            a.Sort();
            for (int i = 0; i < n - 1; i++)
            {
                if ((a[i] < a[i + 1]) && (a[i] * 2 > a[i + 1]))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

//#define FileInput

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Ex2
{
    class Program
    {
        private const int LineCount = 2;

        static void Main(string[] args)
        {
#if FileInput
            string[] inputFile = File.ReadAllLines("Input.txt");
#else
            string[] inputFile = new string[LineCount];
            for (int i=0; i< LineCount; ++i)
                inputFile[i] = Console.ReadLine();
#endif

            string[] vals = inputFile[1].Split(' ');
            long[] lVals = new long[vals.Length];
            for (int i = 0; i < vals.Length; ++i)
            {
                lVals[i]=  Int64.Parse(vals[i]);
            }
            Array.Sort(lVals);

            if (vals.Length < 2)
            {
                Console.WriteLine("NO");
                return;
            }
            for (int i = 0; i < vals.Length - 1; ++i)
            {
                if (lVals[i] == lVals[i + 1])
                    continue;

                if (lVals[i] * 2 > lVals[i + 1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1 {
    class Program {
        static int n;
        static int m;
        static int[] numbers;
        static int first;
        static int second;
        //static int count = 0;
        //static char[,] array;
        static void Main(string[] args) {
            n = int.Parse(Console.ReadLine());
            numbers = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for(int i=0;i<n;i++){
                numbers[i] = int.Parse(s[i]);
            }
            Array.Sort(numbers);
            Console.WriteLine(Check());
            //Console.ReadLine();
        }

        static string Check() {
            for (int i = 0; i < n - 1; i++) {
                if (numbers[i + 1] / numbers[i] < 2 && numbers[i]!=numbers[i+1])
                    return "YES";
            }
            return "NO";
        }
    }
}

using System;
using System.Collections.Generic;
  class Program
    {
        public static void Main(string[] args)
        {
            SortedSet<int> set = new SortedSet<int>();
            {
                string[] input = Console.In.ReadToEnd().Split(new char[] { ' ', '\r', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 1; i < input.Length; ++i)
                    set.Add(int.Parse(input[i]));
            }
            bool result = false;
            {
                int last = 0;
                foreach (int item in set)
                {
                    if (last * 2 > item)
                    { result = true; break; }
                    last = item;
                }
            }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }

using System;
using System.IO;
using System.Text;

namespace Datatypes
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            Array.Sort(nn);

            for (int i = 1; i < nn.Length; i++)
            {
                if (nn[i] != nn[i - 1])
                {
                    if (nn[i] < 2*nn[i - 1])
                    {
                        writer.WriteLine("YES");
                        writer.Flush();
                        return;
                    }
                }
            }

            writer.WriteLine("NO");
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

#define Online

using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.IO;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);

    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            B();

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static void A()
        {
            string[] input = ReadArray(':');
            int h = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            while (true)
            {
                if (m == 59)
                {
                    if (h == 23)
                    {
                        h = 0;
                    }
                    else
                    {
                        h++;
                    }
                    m = 0;
                }
                else
                {
                    m++;
                }
                if (h == (m % 10) * 10 + m / 10)
                {
                    Console.WriteLine((h < 10 ? "0" + h.ToString() : h.ToString()) + ":" + (m < 10 ? "0" + m.ToString() : m.ToString()));
                    return;
                }
            }
        }

        static void B()
        {
            int n = ReadInt();
            string[] tokens = ReadArray(' ');
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = int.Parse(tokens[i]);
            SortedSet<int> hash = new SortedSet<int>();
            for (int i = 0; i < n; i++)
                hash.Add(a[i]);
            int[] _hash = hash.ToArray();
            for (int i = 0; i < _hash.Length - 1; i++)
            {
                if (_hash[i + 1] < _hash[i] * 2)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static string[] ReadArray(char sep)
        {
            return Console.ReadLine().Split(sep);
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }

        public static long GCD(long a, long b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static int GCD(int a, int b)
        {
            while (b != 0) b = a % (a = b);
            return a;
        }

        public static long LCM(long a, long b)
        {
            return (a * b) / GCD(a, b);
        }

        public static int LCM(int a, int b)
        {
            return (a * b) / GCD(a, b);
        }
    }

    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }

    class Graph
    {
        public List<int>[] g;
        public int[] color; //0-white, 1-gray, 2-black
        public int[] o; //open
        public int[] c; //close
        public int[] p;
        public int[] d;
        public List<Edge> e;
        public Stack<int> ans = new Stack<int>();
        public Graph(int n)
        {
            g = new List<int>[n + 1];
            for (int i = 0; i <= n; i++)
                g[i] = new List<int>();
            color = new int[n + 1];
            o = new int[n + 1];
            c = new int[n + 1];
            p = new int[n + 1];
            d = new int[n + 1];
        }

        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public bool DFS(int u, ref int time)
        {
            color[u] = gray;
            time++;
            o[u] = time;
            for (int i = 0; i < g[u].Count; i++)
            {
                int v = g[u][i];
                if (color[v] == gray)
                {
                    return true;
                }
                if (color[v] == white)
                {
                    p[v] = u;
                    if (DFS(v, ref time)) return true;
                }
            }
            color[u] = black;
            ans.Push(u);
            c[u] = time;
            time++;
            return false;
        }
    }

    static class GraphUtils
    {
        const int white = 0;
        const int gray = 1;
        const int black = 2;

        public static void BFS(int s, Graph g)
        {
            Queue<int> q = new Queue<int>();
            q.Enqueue(s);
            while (q.Count != 0)
            {
                int u = q.Dequeue();
                for (int i = 0; i < g.g[u].Count; i++)
                {
                    int v = g.g[u][i];
                    if (g.color[v] == white)
                    {
                        g.color[v] = gray;
                        g.d[v] = g.d[u] + 1;
                        g.p[v] = u;
                        q.Enqueue(v);
                    }
                }
                g.color[u] = black;
            }
        }

        public static bool DFS(int u, ref int time, Graph g, Stack<int> st)
        {
            g.color[u] = gray;
            time++;
            g.o[u] = time;
            for (int i = 0; i < g.g[u].Count; i++)
            {
                int v = g.g[u][i];
                if (g.color[v] == gray)
                {
                    return true;
                }
                if (g.color[v] == white)
                {
                    g.p[v] = u;
                    if (DFS(v, ref time, g, st)) return true;
                }
            }
            g.color[u] = black;
            st.Push(u);
            g.c[u] = time;
            time++;
            return false;
        }

        public static void FordBellman(int u, Graph g)
        {
            int n = g.g.Length;
            for (int i = 0; i <= n; i++)
            {
                g.d[i] = int.MaxValue;
                g.p[i] = 0;
            }

            g.d[u] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < g.e.Count; j++)
                {
                    if (g.d[g.e[j].a] != int.MaxValue)
                    {
                        if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
                        {
                            g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
                            g.p[g.e[j].b] = g.e[j].a;
                        }
                    }
                }
            }
        }
    }

    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R, Comparison<T> comp)
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (comp(L[i], R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R, comp);
            Merge_Sort(A, q + 1, r, L, R, comp);
            Merge(A, p, q, r, L, R, comp);
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) >= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}

using System;
using System.Collections;
using System.Text;

namespace CodeForces_83
{
    class prob_b
    {

        static void Main()
        {
            int n = Int32.Parse (Console.ReadLine());
            int bil, i;
            Hashtable myHash = new Hashtable();
            string[] val = Console.ReadLine().Split(" ".ToCharArray());
            for (i = 0; i < 30; ++i)
                myHash.Add(1<<i, i);

            for (i = 0; i < n; ++i)
            {
                bil = Int32.Parse(val[i]);
                if (!myHash.ContainsKey(bil)) break;
            }
            if (i == n)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }
    }
}

using System;
using System.Collections;
using System.Text;

namespace CodeForces_83
{
    class prob_b
    {

        static void Main()
        {
            int n = Int32.Parse (Console.ReadLine());
            int bil, i;
            Hashtable myHash = new Hashtable();
            string[] val = Console.ReadLine().Split(" ".ToCharArray());
            for (i = 1; i <= 30; ++i)
                myHash.Add(1<<i, i);

            for (i = 0; i < n; ++i)
            {
                bil = Int32.Parse(val[i]);
                if (!myHash.ContainsKey(bil)) break;
            }
            if (i == n)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Task
{
    #region MyIo

    class MyIo : IDisposable
    {
        TextReader inputStream;
        TextWriter outputStream = Console.Out;

        string[] tokens;
        int pointer;

        public MyIo(TextReader inputStream)
        {
            this.inputStream = inputStream;
        }

        public string NextLine()
        {
            try
            {
                return inputStream.ReadLine();
            }
            catch (IOException)
            {
                return null;
            }
        }

        public string NextString()
        {
            try
            {
                while (tokens == null || pointer >= tokens.Length)
                {
                    tokens = NextLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    pointer = 0;
                }
                return tokens[pointer++];
            }
            catch (IOException)
            {
                return null;
            }
        }

        public int NextInt()
        {
            return int.Parse(NextString());
        }

        public long NextLong()
        {
            return long.Parse(NextString());
        }

        public void Print(string format, params object[] args)
        {
            outputStream.Write(format, args);
        }

        public void PrintLine(string format, params object[] args)
        {
            outputStream.WriteLine(format, args);
        }

        public void Print<T>(T o)
        {
            outputStream.Write(o);
        }

        public void Close()
        {
            inputStream.Close();
            outputStream.Close();
        }

        void IDisposable.Dispose()
        {
            Close();
        }
    }
    #endregion

    class Program
    {
        #region Program
        MyIo io;

        public Program(MyIo io)
        {
            this.io = io;
        }

        static void Main(string[] args)
        {
#if  LOCAL_TEST
            using (MyIo io = new MyIo(new StreamReader("input.txt")))
#else
            using (MyIo io = new MyIo(System.Console.In))
#endif

            {
                new Program(io)
                    .Solve();

#if  LOCAL_TEST
                Console.ReadLine();
#endif
            }
        }

        #endregion

        void Solve()
        {
            int n = io.NextInt();

            long[] nums = new long[n];

            for (int i = 0; i < n; i++)
                nums[i] = io.NextLong();

            Array.Sort(nums);

            for (int i = n - 2; i > 0; i--)
            {
                if (nums[n - 1] != nums[i] && nums[n - 1] < (nums[i] << 1))
                {
                    io.Print("YES");
                    return;
                }
            }

            io.Print("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Ex2
{
    class Program
    {
        private const int LineCount = 2;

        static void Main(string[] args)
        {
#if FileInput
            string[] inputFile = File.ReadAllLines("Input.txt");
#else
            string[] inputFile = new string[LineCount];
            for (int i=0; i< LineCount; ++i)
                inputFile[i] = Console.ReadLine();
#endif

            string[] vals = inputFile[1].Split(' ');
            long[] lVals = new long[vals.Length];
            for (int i = 0; i < vals.Length; ++i)
            {
                lVals[i]=  Int64.Parse(vals[i]);
            }
            Array.Sort(lVals);

            if (vals.Length < 2)
            {
                Console.WriteLine("NO");
                return;
            }
            long max = lVals[vals.Length -1];
            long max2 = lVals[vals.Length -2];
            if (max2 * 2 <= max)
            {
                Console.WriteLine("NO");
            }
            else
                Console.WriteLine("YES");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Ex2
{
    class Program
    {
        private const int LineCount = 2;

        static void Main(string[] args)
        {
#if FileInput
            string[] inputFile = File.ReadAllLines("Input.txt");
#else
            string[] inputFile = new string[LineCount];
            for (int i=0; i< LineCount; ++i)
                inputFile[i] = Console.ReadLine();
#endif

            string[] vals = inputFile[1].Split(' ');
            long[] lVals = new long[vals.Length];
            for (int i = 0; i < vals.Length; ++i)
            {
                lVals[i]=  Int64.Parse(vals[i]);
            }
            Array.Sort(lVals);

            if (vals.Length < 2)
            {
                Console.WriteLine("NO");
                return;
            }
            long max = lVals[vals.Length -1];
            long max2 = lVals[0];
            for (int i = vals.Length - 2; i >= 0; --i)
            {
                if (lVals[i] != max)
                    max2 = lVals[i];
                break;
            }

            if (max2 * 2 <= max)
            {
                Console.WriteLine("NO");
            }
            else
                Console.WriteLine("YES");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Ex2
{
    class Program
    {
        private const int LineCount = 2;

        static void Main(string[] args)
        {
#if FileInput
            string[] inputFile = File.ReadAllLines("Input.txt");
#else
            string[] inputFile = new string[LineCount];
            for (int i=0; i< LineCount; ++i)
                inputFile[i] = Console.ReadLine();
#endif

            string[] vals = inputFile[1].Split(' ');
            long currentMax = Int64.Parse(vals[0]);

            for (int i = 1; i < vals.Length; ++i)
            {
                long current = Int64.Parse(vals[i]);
                if (current * 2 > currentMax)
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1 {
    class Program {
        static int n;
        static int m;
        static int[] numbers;
        static int first;
        static int second;
        //static int count = 0;
        //static char[,] array;
        static void Main(string[] args) {
            n = int.Parse(Console.ReadLine());
            numbers = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for(int i=0;i<n;i++){
                numbers[i] = int.Parse(s[i]);
            }
            string result;
            GetFirst();
            GetSecond();
            if (first / second < 2)
                result = "YES";
            else
                result = "NO";
            Console.WriteLine(result);
            //Console.ReadLine();
        }

        static void GetFirst() {
            for (int i = 0; i < n; i++) {
                first = Math.Max(first,numbers[i]);
            }
        }
        static void GetSecond() {
            for (int i = 0; i < n; i++) {
                int tmp = numbers[i];
                if(tmp<first)
                    second = Math.Max(second, tmp);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1 {
    class Program {
        static int n;
        static int m;
        static int[] numbers;
        //static int count = 0;
        //static char[,] array;
        static void Main(string[] args) {
            n = int.Parse(Console.ReadLine());
            numbers = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for(int i=0;i<n;i++){
                numbers[i] = int.Parse(s[i]);
            }
            Sort();
            string result;
            if (numbers[0] / numbers[1] < 2)
                result = "YES";
            else
                result = "NO";
            Console.WriteLine(result);
            //Console.ReadLine();
        }

        static void Sort(){
            for(int i=0;i<n;i++){
                for (int j = 0; j < n - 1; j++) {
                    if (numbers[j] < numbers[j + 1]) {
                        int tmp = numbers[j];
                        numbers[j] = numbers[j + 1];
                        numbers[j + 1] = tmp;
                    }
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1 {
    class Program {
        static int n;
        static int m;
        static int[] numbers;
        static int first;
        static int second;
        //static int count = 0;
        //static char[,] array;
        static void Main(string[] args) {
            n = int.Parse(Console.ReadLine());
            numbers = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for(int i=0;i<n;i++){
                numbers[i] = int.Parse(s[i]);
            }
            Array.Sort(numbers);
            Console.WriteLine(Check());
            //Console.ReadLine();
        }

        static string Check() {
            for (int i = 0; i < n - 1; i++) {
                if (numbers[i + 1] / numbers[i] < 2)
                    return "YES";
            }
            return "NO";
        }
    }
}

using System;
 class Program
    {
        public static void Main(string[] args)
        {
            int[] data;
            {
                string[] input = Console.In.ReadToEnd().Split(new char[] { ' ', '\r', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                data = new int[input.Length];
                for (int i = 1; i < data.Length; ++i)
                    data[i] = int.Parse(input[i]);
            }
            Array.Sort(data, 1, data.Length - 1);
            bool result = false;
            for(int i = 1, lim = data.Length-1; i<lim; ++i)
            {
                if (data[i] * 2 > data[i + 1])
                {
                    result = true;
                    break;
                }
            }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }


Once upon a time in the thicket of the mushroom forest lived mushroom gnomes. They were famous among their neighbors for their magic mushrooms. Their magic nature made it possible that between every two neighboring mushrooms every minute grew another mushroom with the weight equal to the sum of weights of two neighboring ones. The mushroom gnomes loved it when everything was in order, that's why they always planted the mushrooms in one line in the order of their weights' increasing. Well... The gnomes planted the mushrooms and went to eat. After x minutes they returned and saw that new mushrooms had grown up, so that the increasing order had been violated. The gnomes replanted all the mushrooms in the correct order, that is, they sorted the mushrooms in the order of the weights' increasing. And went to eat again (those gnomes were quite big eaters). What total weights modulo p will the mushrooms have in another y minutes?

The first line contains four integers n, x, y, p (1 ≤ n ≤ 106, 0 ≤ x, y ≤ 1018, x + y > 0, 2 ≤ p ≤ 109) which represent the number of mushrooms, the number of minutes after the first replanting, the number of minutes after the second replanting and the module. The next line contains n integers ai which represent the mushrooms' weight in the non-decreasing order (0 ≤ ai ≤ 109). Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

The answer should contain a single number which is the total weights of the mushrooms modulo p in the end after x + y minutes.

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;

class Program
{
    long mod;
    void solve()
    {

        long n = nextLong();
        long x = nextLong();
        long y = nextLong();
        mod = nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong() % mod;
        long res = doIt(n, x, y, a);
        println(res);
    }

    private long doIt(long n, long x, long y, long[] a)
    {
        if (n == 1)
            return a[0];
        long[,] mat = new long[2, 2];
        mat[0, 1] = mat[1, 0] = mat[1, 1] = 1;
        mat = pow(mat, x);
        long S = 0;
        long A = 0;
        for (int i = 1; i < n - 1; i++)
            S = (S + a[i]) % mod;
        A = (a[0] + a[n - 1]) % mod;
        long sum = doItSum(n,x,S,A);
        long max = 0;
        long[] p = new long[] { 0, 1 };
        max = ((p[0] * mat[0, 0] + p[1] * mat[1, 0]) % mod * a[n - 2] % mod + (p[0] * mat[1, 0] + p[1] * mat[1, 1]) % mod * a[n - 1] % mod) % mod;
        long min = a[0];
        long z = (max + min)%mod;
        long s = (sum - z + mod) % mod;
        return doItSum(n, y,s,z);
    }

    private long doItSum(long n, long x,long sum,long A)
    {
        long[,] mat = new long[2, 2];
        mat[0, 0] = mat[0, 1] = 1;
        mat[1, 1] = 3;
        mat = pow(mat, x);
        return (A * mat[0, 0] + sum * mat[1, 0] + A * mat[0, 1] + sum * mat[1, 1]) % mod;

    }

    private long[,] pow(long[,] mat, long p)
    {
        if (p == 0)
        {
            long[,] res = new long[2, 2];
            for (int i = 0; i < 2; i++)
                res[i, i] = 1;
            return res;
        }
        else if (p % 2 == 0)
            return pow(mul(mat, mat), p / 2);
        else
            return mul(mat, pow(mat, p - 1));

    }

    private long[,] mul(long[,] a, long[,] b)
    {
        long[,] c = new long[2, 2];
        for (int i = 0; i < 2; i++)
            for (int j = 0; j < 2; j++)
                for (int k = 0; k < 2; k++)
                    c[i, j] = (c[i, j] + a[i, k] * b[k, j]) % mod;
        return c;
    }

    ////////////
    private void println(int[] ar)
    {
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i]);
            else
                print(ar[i] + " ");
        }
    }
    private void println(int[] ar, bool add)
    {
        int A = 0;
        if (add)
            A++;
        for (int i = 0; i < ar.Length; i++)
        {
            if (i == ar.Length - 1)
                println(ar[i] + A);
            else
                print((ar[i] + A) + " ");
        }
    }

    private void println(string Stringst)
    {
        Console.WriteLine(Stringst);
    }
    private void println(char charnum)
    {
        Console.WriteLine(charnum);
    }
    private void println(int Intnum)
    {
        Console.WriteLine(Intnum);
    }
    private void println(long Longnum)
    {
        Console.WriteLine(Longnum);
    }
    private void println(double Doublenum)
    {
        string s = Doublenum.ToString(CultureInfo.InvariantCulture);
        Console.WriteLine(s);
    }

    private void print(string Stringst)
    {
        Console.Write(Stringst);
    }
    private void print(int Intnum)
    {
        Console.Write(Intnum);
    }
    private void print(char charnum)
    {
        Console.Write(charnum);
    }
    private void print(long Longnum)
    {
        Console.Write(Longnum);
    }
    private void print(double Doublenum)
    {
        Console.Write(Doublenum);
    }

    string[] inputLine = new string[0];
    int inputInd = 0;
    string nextLine()
    {
        return Console.ReadLine();
    }
    void readInput()
    {
        if (inputInd != inputLine.Length)
            throw new Exception();
        inputInd = 0;
        inputLine = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (inputLine.Length == 0)
            readInput();

    }
    int nextInt()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return int.Parse(inputLine[inputInd++]);
    }
    long nextLong()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return long.Parse(inputLine[inputInd++]);
    }
    double nextDouble()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return double.Parse(inputLine[inputInd++]);
    }
    string nextString()
    {
        if (inputInd == inputLine.Length)
            readInput();
        return inputLine[inputInd++];
    }
    static void Main(string[] args)
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        new Program().solve();
    }
}


The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.

The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109).

Output the number of the highest suitable branch. If there are none, print -1 instead.

NoteIn the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.It immediately follows that there are no valid branches in second sample case.

using System;

namespace CSharp
{
    class _937B
    {
        public static void Main()
        {
            var tokens = Console.ReadLine().Split();

            int p = int.Parse(tokens[0]);
            int y = int.Parse(tokens[1]);

            for (; y > p; y--)
            {
                bool suitable = true;

                for (int i = 2; i <= p && i <= y / i; i++)
                {
                    if (y % i == 0)
                    {
                        suitable = false;
                        break;
                    }
                }

                if (suitable)
                {
                    Console.WriteLine(y);
                    return;
                }
            }

            Console.WriteLine(-1);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Vile_Grasshoppers
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static int Solve(string[] args)
        {
            int p = Next();
            int y = Next();

            if (y%2 == 0)
                y--;

            while (true)
            {
                bool ok = true;
                for (int i = 3; i <= p && i*i <= y; i += 2)
                {
                    if (y%i == 0)
                    {
                        ok = false;
                        break;
                    }
                }

                if (ok)
                    break;

                y -= 2;
            }

            if (p < y)
                return y;

            return -1;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;

namespace CodeforcesTemplate
{
    public static class Permutation
    {
        private static bool Next(ref int[] arr)
        {
            int k, j, l;
            for (j = arr.Length - 2; (j >= 0) && (arr[j] >= arr[j + 1]); j--) { }
            if (j == -1)
            {
                arr = arr.OrderBy(c => c).ToArray();
                return false;
            }
            for (l = arr.Length - 1; (arr[j] >= arr[l]) && (l >= 0); l--) { }
            var tmp = arr[j];
            arr[j] = arr[l];
            arr[l] = tmp;
            for (k = j + 1, l = arr.Length - 1; k < l; k++, l--)
            {
                tmp = arr[k];
                arr[k] = arr[l];
                arr[l] = tmp;
            }
            return true;
        }
        public static IEnumerable<int[]> AllPermutations(int[] arr)
        {
            do yield return arr;
            while (Next(ref arr));
        }
    }

    class Program
    {
        private const string FILENAME = "distance4";

        private const string INPUT = FILENAME + ".in";

        private const string OUTPUT = FILENAME + ".out";

        private static Stopwatch _stopwatch = new Stopwatch();

        private static StreamReader _reader = null;
        private static StreamWriter _writer = null;

        private static string[] _curLine;
        private static int _curTokenIdx;

        private static char[] _whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public static string Check(string s)
        {
            string letters = "aeiouy";

            while (true)
            {
                bool used = false;

                for (int i = 0; i < s.Length - 1; i++)
                {
                    if (letters.Contains(s[i].ToString()) && letters.Contains(s[i + 1].ToString()))
                    {
                        s = s.Remove(i + 1, 1);

                        used = true;
                    }
                }

                if (!used)
                {
                    return s;
                }
            }
        }

        private static string ReadNextToken()
        {
            if (_curTokenIdx >= _curLine.Length)
            {
                //Read next line
                string line = _reader.ReadLine();
                if (line != null)
                    _curLine = line.Split(_whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    _curLine = new string[] { };
                _curTokenIdx = 0;
            }

            if (_curTokenIdx >= _curLine.Length)
                return null;

            return _curLine[_curTokenIdx++];
        }

        private static int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        private static void RunTimer()
        {
#if (DEBUG)

            _stopwatch.Start();

#endif
        }

        private static void Main(string[] args)
        {

#if (DEBUG)
            double before = GC.GetTotalMemory(false);
#endif

            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int p = a[0];
            int y = a[1];

            for (int i = y; i > p; i--)
            {
                bool ok = true;

                for (int j = 2; j <= p && j * j <= i; j++)
                {
                    if (i % j == 0)
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(-1);

#if (DEBUG)
            _stopwatch.Stop();

            double after = GC.GetTotalMemory(false);

            double consumedInMegabytes = (after - before) / (1024 * 1024);

            Console.WriteLine($"Time elapsed: {_stopwatch.Elapsed}");

            Console.WriteLine($"Consumed memory (MB): {consumedInMegabytes}");

            Console.ReadKey();
#endif

        }

        private static int CountLeadZeros(string source)
        {
            int countZero = 0;

            for (int i = source.Length - 1; i >= 0; i--)
            {
                if (source[i] == '0')
                {
                    countZero++;
                }

                else
                {
                    break;
                }

            }

            return countZero;
        }

        private static string ReverseString(string source)
        {
            char[] reverseArray = source.ToCharArray();

            Array.Reverse(reverseArray);

            string reversedString = new string(reverseArray);

            return reversedString;
        }

        private static int[] CopyOfRange(int[] src, int start, int end)
        {
            int len = end - start;
            int[] dest = new int[len];
            Array.Copy(src, start, dest, 0, len);
            return dest;
        }

        private static string StreamReader()
        {

            if (_reader == null)
                _reader = new StreamReader(INPUT);
            string response = _reader.ReadLine();
            if (_reader.EndOfStream)
                _reader.Close();
            return response;

        }

        private static void StreamWriter(string text)
        {

            if (_writer == null)
                _writer = new StreamWriter(OUTPUT);
            _writer.WriteLine(text);

        }

        private static int BFS(int start, int end, int[,] arr)
        {
            Queue<KeyValuePair<int, int>> queue = new Queue<KeyValuePair<int, int>>();
            List<bool> visited = new List<bool>();
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                visited.Add(false);
            }

            queue.Enqueue(new KeyValuePair<int, int>(start, 0));
            KeyValuePair<int, int> node;
            int level = 0;
            bool flag = false;

            while (queue.Count != 0)
            {
                node = queue.Dequeue();
                if (node.Key == end)
                {
                    return node.Value;
                }
                flag = false;
                for (int i = 0; i < arr.GetLength(0); i++)
                {

                    if (arr[node.Key, i] == 1)
                    {
                        if (visited[i] == false)
                        {
                            if (!flag)
                            {
                                level = node.Value + 1;
                                flag = true;
                            }
                            queue.Enqueue(new KeyValuePair<int, int>(i, level));
                            visited[i] = true;
                        }
                    }
                }

            }
            return 0;

        }

        private static void Write(string source)
        {
            File.WriteAllText(OUTPUT, source);
        }

        private static string ReadString()
        {
            return File.ReadAllText(INPUT);
        }

        private static void WriteStringArray(string[] source)
        {
            File.WriteAllLines(OUTPUT, source);
        }

        private static string[] ReadStringArray()
        {
            return File.ReadAllLines(INPUT);
        }

        private static int[] GetIntArray()
        {
            return ReadString().Split(' ').Select(int.Parse).ToArray();
        }

        private static double[] GetDoubleArray()
        {
            return ReadString().Split(' ').Select(double.Parse).ToArray();
        }

        private static int[,] ReadINT2XArray(List<string> lines)
        {
            int[,] arr = new int[lines.Count, lines.Count];

            for (int i = 0; i < lines.Count; i++)
            {
                int[] row = lines[i].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();

                for (int j = 0; j < lines.Count; j++)
                {
                    arr[i, j] = row[j];
                }
            }

            return arr;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces
{
   class B
   {
     static void Main(string[] args)
     {
       string[] token = Console.ReadLine().Split();

       int p = int.Parse(token[0]);
       int y = int.Parse(token[1]);

       int ans = -1;

       for(int i=y;i>p;i--){
         if(IsPrime(i,p)){
           Console.WriteLine(i);
           return;
         }
       }

       Console.WriteLine(-1);

     }

     static bool IsPrime(int n,int p){
       for(int i=2;i<=Math.Min(Math.Sqrt(n),p);i++){
         if(n%i==0){
           return false;
         }
       }
       return true;
     }

   }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace program
{
      class Program
      {
            static void Main(string[] args)
            {
                  string[] arr = Console.ReadLine().Split(' ');
                  int a = int.Parse(arr[0]);
                  int b = int.Parse(arr[1]);

                  for (int i = b; i > a; i--)
                  {
                        if (Prime(i, a))
                        {
                              Console.WriteLine(i);
                              return;
                        }
                  }
                  Console.WriteLine(-1);
            }
            static bool Prime(int x, int a)
            {
                  if (x == 2)
                        return true;
                  for (int i = 2; i <= Math.Min(Math.Sqrt(x), a); i++)
                        if (x % i == 0)
                              return false;
                  return true;
            }
      }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _937B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var timer = new Stopwatch();
            timer.Start();
            var parsedInput = input.Split(' ').Select(x => int.Parse(x)).ToList();
            int hoppers = parsedInput[0];
            int branches = parsedInput[1];

            int result = Calculate(branches, hoppers);

            Console.WriteLine(result);
            timer.Stop();
            //Console.WriteLine(timer.ElapsedMilliseconds);
            Console.ReadLine();
        }

        private static int Calculate(int branches, int hoppers)
        {
            for (int i = branches; i > hoppers; i--)
            {
                bool isSimple = true;
                int top = Math.Min((int)Math.Sqrt(branches), hoppers);
                for (int j = 2; j <= top; j++)
                {
                    if (i % j == 0)
                    {
                        isSimple = false;
                        break;
                    }
                }

                if (isSimple)
                    return i;
            }

            return -1;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Codeforces2502B
{
    class Program
    {

        static long smallestDiv(long n)
        {
            for(long i= 2;i<= Math.Sqrt(n);i++)
            {
                if (n % i == 0)
                    return i;
            }

            return 1;
        }

        static void Main(string[] args)
        {
            string read;
            read = Console.ReadLine();
            long p = long.Parse(read.Split(' ').ToList()[0]);
            long n = long.Parse(read.Split(' ').ToList()[1]);
            long sd,output = -1;
            for(long i=n;i>p;i--)
            {
                sd = smallestDiv(i);
                if(sd > p || sd ==1)
                {
                    output = i;
                    break;
                }
            }

            Console.WriteLine(output);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace Testriep
{
    public class Program
    {

        public static void Main(string[] args)
        {
            var line=Console.ReadLine().Split(' ');
            var p = int.Parse(line[0]);
            var h = int.Parse(line[1]);
            if (h % 2 == 0)
            {
                h--;
            }
            while (h > p)
            {
                if (isGood(h,p))
                {
                    Console.WriteLine(h);
                    return;
                }
                h -= 2;
            }
            Console.WriteLine(-1);
            //Console.WriteLine(Console.ReadLine().Split(' ').Select(e => int.Parse(e)).Where(e => e != 0).Distinct().Count());
        }

        static bool isGood(int n,int p)
        {
            int sqrt = (int)(Math.Sqrt((double)n)+1);
            int limit = Math.Min(sqrt, p);
           for(int i = 2; i <= limit; i++)
            {
                if (n % i == 0)
                {
                    return false;
                }
            }
            return true;
        }
}
}

using System;
using System.Linq;

namespace PorblemB
{
	public static class Common
	{
		public static int[] ReadAndParseLine()
		{
			return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		}
	}

	public class Problem
	{
		public int p;
		public int y;

		bool IsPrime(int c)
		{
			if (c <= 2)
				return false;
			var l = Math.Min((int)Math.Sqrt(c), p);
			for (int i = 2; i <= l; i++)
				if (c % i == 0) return false;
			return true;
		}

		public Problem()
		{
			var data = Common.ReadAndParseLine();
			p = data[0];
			y = data[1];
		}

		public void Solve()
		{
			while (!IsPrime(y) && y > 2)
				y--;
			Console.WriteLine(y > p ? y : -1);
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			new Problem().Solve();
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acyclic
{
    class B467
    {
        public static void Main()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            double p = Int32.Parse(tmp[0]);
            int y = Int32.Parse(tmp[1]);

            SortedSet<int> primes = new SortedSet<int>();
            int range = (int)Math.Max(p, Math.Floor(y / p));

            DateTime t = DateTime.Now;
            int x = y;
            while(x!=p)
            {
                bool flag = true;

                for (long i=2;i<=p && i*i<=x;i++)
                {

                    if ((x % i) == 0)
                    {
                        flag = false;
                        break;
                    }
                }
                if(flag)
                {
                    Console.WriteLine(x);
                    //Console.WriteLine(DateTime.Now - t);
                    return;
                }
                x--;
            }
            if (x == p) Console.WriteLine(-1);
            //Console.WriteLine(DateTime.Now - t);

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
    // To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
    const bool testing = true;
#else
const bool testing = false;
#endif
    static List<double> GetAllGcd(double num)
    {
        var all = new List<double>();
        for (double i = 2; i * i <= num; i++)
        {
            if (num % i == 0)
            {
                all.Add(i);
            }
            if (num % i == 0 && num / i != i)
            {
                all.Add(num / i);
            }
        }
        return all;
    }
    static void program(TextReader input)
    {
        //var n = int.Parse(input.ReadLine());
        var data = input.ReadLine().Split(' ').Select(double.Parse).ToList();
        var p = data[0];
        var y = data[1];
        for(double i = y; i > p; i--)
        {
            var gcds = GetAllGcd(i);
            if (gcds.Where(a => a <= p).ToList().Count == 0) {
                Console.WriteLine(i);
                return;
            };
        }
        Console.WriteLine(-1);
    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("5\n");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("3 6\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("-1\n");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("3 4\n"));
        Console.WriteLine();

    }
}

using System;
using System.Collections.Generic;

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R467B.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R467B();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R467B : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            var ints = this.ReadIntArray();
            var p = ints[0];
            var y = ints[1];
            if (y % 2 == 0)
            {
                y--;
            }

            var result = -1;
            for (int i = y; i > p ; i=i-2)
            {
                if (this.IsPrimeLimited(i, p))
                {
                    result = i;
                    break;
                }
            }

            yield return result.ToString();
        }

        private bool IsPrimeLimited(long number, long p)
        {
            if (number <= 0)
            {
                throw new ArgumentException("Must be positive", nameof(number));
            }
            if (number == 1)
            {
                return false;
            }
            if (number < 4)
            {
                return true;
            }
            if (number % 2 == 0)
            {
                return false;
            }
            if (number % 3 == 0 && p>=3)
            {
                return false;
            }
            for (int i = 5; i * i <= number && i<=p; i = i + 6)
            {
                if (number % i == 0 || (number % (i + 2) == 0 && i+2<=p))
                {
                    return false;
                }
            }
            return true;
        }

    }
    internal class R467C : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }
    internal class R467D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        /// <summary>
        /// Pring array of T
        /// </summary>
        /// <typeparam name="T">Generic paramter.</typeparam>
        /// <param name="items">The items.</param>
        /// <param name="prefixMessage">The message shown first.</param>
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}

using System;

public class Program
{
	public static void Main()
	{
		 string[] token = Console.ReadLine().Split();

       int p = int.Parse(token[0]);
       int y = int.Parse(token[1]);

       for(int i=y;i>=p;i--){
         if(IsPrime(i,p)){
           Console.WriteLine(i);
           return;
         }
       }

       Console.WriteLine(-1);
	}

	static bool IsPrime(int n,int p){
       for(int i=2;i<=Math.Min(Math.Sqrt(n),p);i++){
         if(n%i==0){
           return false;
         }
       }
       return true;
     }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace program
{
      class Program
      {
            static void Main(string[] args)
            {
                  string[] arr = Console.ReadLine().Split(' ');
                  int a = int.Parse(arr[0]);
                  int b = int.Parse(arr[1]);

                  for (int i = a + 1; i <= b; i++)
                  {
                        if (Prime(i))
                        {
                              Console.WriteLine(i);
                              return;
                        }
                  }
                  Console.WriteLine(-1);
            }
            static bool Prime(int x)
            {
                  if (x == 2)
                        return true;
                  if (x % 2 == 0)
                        return false;
                  for (int i = 3; i * i < x; i += 2)
                        if (x % i == 0)
                              return false;
                  return true;
            }
      }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace program
{
      class Program
      {
            static void Main(string[] args)
            {
                  string[] arr = Console.ReadLine().Split(' ');
                  int a = int.Parse(arr[0]);
                  int b = int.Parse(arr[1]);

                  for (int i = b; i > a; i--)
                  {
                        if (Prime(i))
                        {
                              Console.WriteLine(i);
                              return;
                        }
                  }
                  Console.WriteLine(-1);
            }
            static bool Prime(int x)
            {
                  if (x == 2)
                        return true;
                  if (x % 2 == 0)
                        return false;
                  for (int i = 3; i * i < x; i += 2)
                        if (x % i == 0)
                              return false;
                  return true;
            }
      }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _937B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var timer = new Stopwatch();
            timer.Start();
            var parsedInput = input.Split(' ').Select(x => int.Parse(x)).ToList();
            int hoppers = parsedInput[0];
            int branches = parsedInput[1];

            TightBoolList occupations = new TightBoolList(branches);
            occupations[0] = true;
            occupations[1] = true;

            int top = (int)Math.Sqrt(branches);
            for (int i = 2; i <= hoppers && i <= top; i++)
            {
                if (occupations[i])
                    continue;

                int start = (hoppers + 1) + (i - (hoppers + 1) % i);
                for (int j = start; j <= branches; j += i)
                {
                    occupations[j] = true;
                }
            }

            int result = -1;
            for (int i = hoppers + 1; i <= branches; i++)
            {
                if (!occupations[i])
                    result = i;
            }

            Console.WriteLine(result);
            timer.Stop();
            //Console.WriteLine(timer.ElapsedMilliseconds);
            Console.ReadLine();
        }

        class TightBoolList
        {
            private List<byte> UnderlyingList;

            public int Size { get; private set; }

            public TightBoolList(int size)
            {
                Size = size;
                int capacity = (int)Math.Ceiling(size / 8d) + 1;
                UnderlyingList = new List<byte>(capacity);
                for (int i = 0; i < capacity; i++)
                {
                    UnderlyingList.Add(0);
                }
            }

            public bool this[int i]
            {
                get
                {
                    int index = i / 8;
                    int innerIndex = i % 8;
                    byte containing = UnderlyingList[index];
                    return (containing & (1 << innerIndex)) > 0;
                }
                set
                {
                    int index = i / 8;
                    int innerIndex = i % 8;
                    byte containing = UnderlyingList[index];
                    UnderlyingList[index] = (byte)(containing | (1 << innerIndex));
                }
            }
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _937B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var timer = new Stopwatch();
            timer.Start();
            var parsedInput = input.Split(' ').Select(x => int.Parse(x)).ToList();
            int hoppers = parsedInput[0];
            int branches = parsedInput[1];

            int result;
            if (branches == 2)
            {
                result = CalculateTwoHoppers(branches);
            }
            else
            {
                int sieveResult = SmartSieve((hoppers - 1) / 2, (branches - 1) / 2);
                result = sieveResult * 2 + 1;
            }

            Console.WriteLine(result);
            timer.Stop();
            Console.WriteLine(timer.ElapsedMilliseconds);
            Console.ReadLine();
        }

        private static int SmallerOrEqualOdd(int value)
        {
            return ((value - 1) >> 1 << 1) + 1;
        }

        private static int CalculateTwoHoppers(int branches)
        {
            return branches > 2 ? SmallerOrEqualOdd(branches) : -1;
        }

        private static int SmartSieve(int iterateFor, int size)
        {
            Indexer occupations = new ListIndexedFromOne(size);
            int top = Math.Min((int)(Math.Sqrt(size * 2 + 1) - 1) / 2, iterateFor);
            for (int i = 1; i <= top; i++)
            {
                int next = Math.Max(i, (iterateFor - i) / (2 * i + 1));
                for (int j = next; ; j += 1)
                {
                    int resultIndex = 2 * i * j + i + j;
                    if (resultIndex <= size)
                    {
                        occupations[resultIndex] = true;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            for (int i = size; i > iterateFor; i--)
            {
                if (!occupations[i])
                    return i;
            }

            return -1;
        }

        public interface Indexer
        {
            bool this[int index]
            {
                get;
                set;
            }
        }

        public class ListIndexedFromOne : Indexer
        {
            private BitArray Array;

            public ListIndexedFromOne(int size)
            {
                Array = new BitArray(size);
            }

            public bool this[int index]
            {
                get
                {
                    return Array[index - 1];
                }
                set
                {
                    Array[index - 1] = value;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _937B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var timer = new Stopwatch();
            timer.Start();
            var parsedInput = input.Split(' ').Select(x => int.Parse(x)).ToList();
            int hoppers = parsedInput[0];
            int branches = parsedInput[1];

            TightBoolList occupations = new TightBoolList(branches);
            occupations[0] = true;
            occupations[1] = true;

            int top = (int)Math.Sqrt(branches);
            for (int i = 2; i <= hoppers && i <= top; i++)
            {
                if (occupations[i])
                    continue;

                int start = (hoppers + 1) + (i - (hoppers + 1) % i);
                for (int j = start; j <= branches; j += i)
                {
                    occupations[j] = true;
                }
            }

            int result = -1;
            for (int i = hoppers + 1; i <= branches; i++)
            {
                if (!occupations[i])
                    result = i;
            }

            Console.WriteLine(result);
            timer.Stop();
            Console.WriteLine(timer.ElapsedMilliseconds);
            Console.ReadLine();
        }

        class TightBoolList
        {
            private List<byte> UnderlyingList;

            public int Size { get; private set; }

            public TightBoolList(int size)
            {
                Size = size;
                int capacity = (int)Math.Ceiling(size / 8d) + 1;
                UnderlyingList = new List<byte>(capacity);
                for (int i = 0; i < capacity; i++)
                {
                    UnderlyingList.Add(0);
                }
            }

            public bool this[int i]
            {
                get
                {
                    int index = i / 8;
                    int innerIndex = i % 8;
                    byte containing = UnderlyingList[index];
                    return (containing & (1 << innerIndex)) > 0;
                }
                set
                {
                    int index = i / 8;
                    int innerIndex = i % 8;
                    byte containing = UnderlyingList[index];
                    UnderlyingList[index] = (byte)(containing | (1 << innerIndex));
                }
            }
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _937B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var timer = new Stopwatch();
            timer.Start();
            var parsedInput = input.Split(' ').Select(x => int.Parse(x)).ToList();
            int hoppers = parsedInput[0];
            int branches = parsedInput[1];

            int result = Calculate(branches, hoppers);

            Console.WriteLine(result);
            timer.Stop();
            //Console.WriteLine(timer.ElapsedMilliseconds);
            Console.ReadLine();
        }

        private static int Calculate(int branches, int hoppers)
        {
            for (int i = branches; i > hoppers; i--)
            {
                bool isSimple = true;
                int top = (int)Math.Sqrt(branches);
                for (int j = 2; j <= top; j++)
                {
                    if (i % j == 0)
                    {
                        isSimple = false;
                        break;
                    }
                }

                if (isSimple)
                    return i;
            }

            return -1;
        }
    }
}

using System;
using System.Linq;

namespace PorblemB
{
	public static class Common
	{
		public static int[] ReadAndParseLine()
		{
			return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		}
	}

	public class Problem
	{
		public int p;
		public int y;

		bool IsPrime(int c)
		{
			if (c <= 2)
				return false;
			var l = (int)Math.Sqrt(c) + 1;
			for (int i = 2; i <= l; i++)
				if (c % i == 0) return false;
			return true;
		}

		public Problem()
		{
			var data = Common.ReadAndParseLine();
			p = data[0];
			y = data[1];
		}

		public void Solve()
		{
			while (!IsPrime(y) && y > 2)
				y--;
			Console.WriteLine(y > p ? y : -1);
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			new Problem().Solve();
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PorblemB
{
	public static class Common
	{
		public static int[] ReadAndParseLine()
		{
			return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
		}
	}

	public class Problem
	{
		public int p;
		public int y;

		bool IsPrime(int c)
		{
			if (c < 2)
				return false;
			var l = (int)Math.Sqrt(c);
			for (int i = 2; i <= l; i++)
				if (c % i == 0) return false;
			return true;
		}

		public Problem()
		{
			var data = Common.ReadAndParseLine();
			p = data[0];
			y = data[1];
		}

		public void Solve()
		{
			while (!IsPrime(y) && y > p) y--;
			Console.Write(y > p ? y : -1);
		}
	}

	class Program
	{
		static void Main(string[] args)
		{
			new Problem().Solve();
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acyclic
{
    class B467
    {
        public static void Main()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            double p = Int32.Parse(tmp[0]);
            int y = Int32.Parse(tmp[1]);

            int x = y;
            while(x!=p)
            {
                bool flag = true;
                int range = (int)Math.Max(p, Math.Floor(y / p));
                for(long i=2;i<=range;i++)
                {
                    if ((x % i) == 0)
                    {
                        flag = false;
                        break;

                    }
                }
                if(flag)
                {
                    Console.WriteLine(x);
                    return;
                }
                x--;
            }
            if (x == p) Console.WriteLine(-1);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acyclic
{
    class B467
    {
        public static void Main()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            double p = Int32.Parse(tmp[0]);
            int y = Int32.Parse(tmp[1]);

            int x = y;
            while(x!=p)
            {
                bool flag = true;
                int range = (int)Math.Max(p, Math.Floor(y / p));
                int low = (int)Math.Min(p, Math.Floor(y / p));
                for (long i=2;i<=range;i++)
                {
                    if ((x % i) == 0)
                    {
                        if (x / i <= low)
                        {
                            flag = false;
                            break;
                        }

                    }
                }
                if(flag)
                {
                    Console.WriteLine(x);
                    return;
                }
                x--;
            }
            if (x == p) Console.WriteLine(-1);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Acyclic
{
    class B467
    {
        public static void Main()
        {
            string[] tmp = Console.ReadLine().Split(' ');
            double p = Int32.Parse(tmp[0]);
            int y = Int32.Parse(tmp[1]);

            SortedSet<int> primes = new SortedSet<int>();
            int range = (int)Math.Max(p, Math.Floor(y / p));

            DateTime t = DateTime.Now;
            int x = y;
            while(x!=p)
            {
                bool flag = true;

                for (long i=2;i<=p && i*i<x;i++)
                {

                    if ((x % i) == 0)
                    {
                        flag = false;
                        break;
                    }
                }
                if(flag)
                {
                    Console.WriteLine(x);
                    //Console.WriteLine(DateTime.Now - t);
                    return;
                }
                x--;
            }
            if (x == p) Console.WriteLine(-1);
            //Console.WriteLine(DateTime.Now - t);

        }
    }
}

using System;
using System.Collections.Generic;

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R467B.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R467B();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R467B : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            var ints = this.ReadIntArray();
            var p = ints[0];
            var y = ints[1];
            if (y % 2 == 0)
            {
                y--;
            }

            var result = -1;
            for (int i = y; i > p ; i=i-2)
            {
                if (this.IsPrimeLimited(i, p))
                {
                    result = i;
                    break;
                }
            }

            yield return result.ToString();
        }

        private bool IsPrimeLimited(long number, long p)
        {
            if (number <= 0)
            {
                throw new ArgumentException("Must be positive", nameof(number));
            }
            if (number == 1)
            {
                return false;
            }
            if (number < 4)
            {
                return true;
            }
            if (number % 2 == 0)
            {
                return false;
            }
            if (number % 3 == 0 && p>=3)
            {
                return false;
            }
            for (int i = 5; i * i <= number && i<=p; i = i + 6)
            {
                if (number % i == 0 || number % (i + 2) == 0)
                {
                    return false;
                }
            }
            return true;
        }

    }
    internal class R467C : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }
    internal class R467D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        /// <summary>
        /// Pring array of T
        /// </summary>
        /// <typeparam name="T">Generic paramter.</typeparam>
        /// <param name="items">The items.</param>
        /// <param name="prefixMessage">The message shown first.</param>
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}

using System;
using System.Collections.Generic;

namespace CodeForces
{
    static class Program
    {
        static void Main()
        {
            const string filePath = @"Data\R467B.txt";
            if (System.IO.File.Exists(filePath))
            {
                Console.SetIn(new System.IO.StreamReader(filePath));
            }

            IProblem counter = new R467B();

            foreach (var result in counter.GetResults())
            {
                Console.WriteLine(result);
            }
        }
    }

    internal class R467B : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            var ints = this.ReadIntArray();
            var p = ints[0];
            var y = ints[1];
            if (y % 2 == 0)
            {
                y--;
            }

            var result = -1;
            for (int i = y; i > p ; i=i-2)
            {
                if (this.IsPrimeLimited(i, p))
                {
                    result = i;
                    break;
                }
            }

            yield return result.ToString();
        }

        private bool IsPrimeLimited(long number, long p)
        {
            if (number <= 0)
            {
                throw new ArgumentException("Must be positive", nameof(number));
            }
            if (number == 1)
            {
                return false;
            }
            if (number < 4)
            {
                return true;
            }
            if (number % 2 == 0)
            {
                return false;
            }
            if (number % 3 == 0 && p>3)
            {
                return false;
            }
            for (int i = 5; i * i <= number && i<=p; i = i + 6)
            {
                if (number % i == 0 || number % (i + 2) == 0)
                {
                    return false;
                }
            }
            return true;
        }

    }
    internal class R467C : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }
    internal class R467D : ProblemBase
    {
        public override IEnumerable<string> GetResults()
        {
            yield return "n/a";
        }
    }

    abstract class MultipleTestsBase : ProblemBase
    {
        public sealed override IEnumerable<string> GetResults()
        {
            var t = Convert.ToInt32(Console.ReadLine());
            for (int testCaseNumber = 0; testCaseNumber < t; testCaseNumber++)
            {
                foreach (var result in GetTestResult(testCaseNumber + 1))
                {
                    yield return result;
                }

            }

        }

        protected abstract IEnumerable<string> GetTestResult(int caseNumber);
    }

    public interface IProblem
    {
        IEnumerable<string> GetResults();
    }

    public abstract class ProblemBase : IProblem
    {
        /// <summary>
        /// Pring array of T
        /// </summary>
        /// <typeparam name="T">Generic paramter.</typeparam>
        /// <param name="items">The items.</param>
        /// <param name="prefixMessage">The message shown first.</param>
        public void PrintArray<T>(IEnumerable<T> items, string prefixMessage)
        {
            Console.WriteLine("{0}: {1}", prefixMessage, string.Join(",", items));
        }

        public void WriteDiagnostics(string message, params object[] objects)
        {
            Console.WriteLine(message, objects);
        }

        public virtual IEnumerable<string> GetResults()
        {
            yield return "No result";
        }

        protected int[] ReadIntArray()
        {
            return Array.ConvertAll(ReadTokens(), Convert.ToInt32);
        }

        protected string[] ReadTokens()
        {
            var readLine = Console.ReadLine();
            if (readLine == null)
            {
                throw new Exception("Value read from Console is null");
            }
            return readLine.Split(' ');
        }

        protected int ReadInt32()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
    }
}