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


namespace Atcoder01
{
    /*class Program
    {
        //ABC96B
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = int.Parse(Console.ReadLine());
            Array.Sort(input);
            int Ans = input[0] + input[1];
            var ans = input.Max();
            for (int i = 0; i < N; i++)
            {
                ans = ans * 2;
            }
            Console.WriteLine(ans + Ans);
        }
    }*/
    //ABC94B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] gate = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int X = input[2];
            int cost1 = 0;
            int cost2 = 0;
            for (int i = 0;i<X;i++)
            {
                if (gate.Contains(i))
                {
                    cost1++;
                }
            }
            for (int i = X;i<= N+1;i++)
            {
                if (gate.Contains(i))
                {
                    cost2++;
                }
            }
            List<int> Answer = new List<int>();
            Answer.Add(cost1);
            Answer.Add(cost2);
            Console.WriteLine(Answer.Min());
        }
    }*/
    //ABC93B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            int K = input[2];
            List<BigInteger> array = new List<BigInteger>();
            List<BigInteger> answer = new List<BigInteger>();
            for (BigInteger i = A;i<=B;i++)
            {
                array.Add(i);
            }
            for(BigInteger i =A;i<A+K;i++)
            {
                answer.Add(i);
            }
            for (BigInteger i = B; i > B-K;i--)
            {
                answer.Add(i);
            }
            answer.Sort();
            IEnumerable<BigInteger> result = answer.Distinct();
            foreach (BigInteger aa in result)
            {
                if (array.Contains(aa)) {
                    Console.WriteLine(aa);
                }
            }
        }*/
    /*static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int A = input[0];
        int B = input[1];
        int K = input[2];
        List<int> ans1 = new List<int>();
        for (int i=A;i<A+K;i++)
        {
            ans1.Add(i);
        }
        for (int i =B-K+1;i<=B;i++)
        {
            ans1.Add(i);
        }
        ans1.Sort();
        IEnumerable<int> result = ans1.Distinct();
        foreach (BigInteger aa in result)
        {
            if (A<=aa && aa<=B) {
                Console.WriteLine(aa);
            }
        }
       }
    }*/
    //ABC92B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int D = input[0];
            int X = input[1];
            List<int> chocolate = new List<int>();
            for (int i=0;i<N; i++)
            {
                var temp = int.Parse(Console.ReadLine());
                chocolate.Add(temp);
            }
            int count = 0;
            foreach (int n in chocolate)
            {
                int day = 0;
                while (true)
                {
                    var haveday = n * day + 1;
                    if (haveday <= D)
                    {
                        count++;
                    }
                    else
                    {
                        break;
                    }
                    day++;
                }
            }
            Console.WriteLine(count + X);
        }
    }*/
    //ABC89B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            bool flag = false;
            char[] arare = Console.ReadLine().ToCharArray();
            foreach (char n in arare)
            {
                if (n == 'Y')
                {
                    flag = true;
                }
            }
            if (flag == true)
            {
                Console.WriteLine("Four");
            }
            else
            {
                Console.WriteLine("Three");
            }
        }
    }*/
    //ABC86B
    /*class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split();
            var a = input[0] + input[1];
            int Ans = Convert.ToInt32(a.ToString());
            double mm = Math.Sqrt((double)Ans);
            if (mm == (int)mm)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }*/
    //ABC84B
    /*class Program 
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            var S = Console.ReadLine();
            if (S.Length == A + B + 1)
            {
                for (int i = 0; i < S.Length; i++)
                {
                    if (A == i)
                    {
                        if (S[i] == '-')
                        {
                            var temp1 = S.Substring(0, i);
                            if (temp1.All(char.IsDigit))
                            {
                                temp1 = S.Substring(i + 1, S.Length - (i+1));
                                if (temp1.All(char.IsDigit))
                                {
                                    Console.WriteLine("Yes");
                                }
                                else
                                {
                                    Console.WriteLine("No");
                                }
                            }
                            else
                            {
                                Console.WriteLine("No");
                            }
                        }
                        else
                        {
                            Console.WriteLine("No");
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }*/
    //ABC79B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<BigInteger> ryka = new List<BigInteger>();
            ryka.Add(2);
            ryka.Add(1);
            int count = 2;
            while (count <= N)
            {
                var temp = ryka[count - 2] + ryka[count - 1];
                ryka.Add(temp);
                count++;
            }
            Console.WriteLine(ryka[N]);
        }
    }*/
    //ABC78B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = input[0];
            int Y = input[1];
            int Z = input[2];
            int M = X / Y;
            while (true)
            {
                var temp = Y * M + (M + 1) * Z;
                if (temp <= X)
                {
                    Console.WriteLine(M);
                    break;
                }
                else
                {
                    M--; 
                }
            }
        }
    }*/
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int Answer = 0;
            while(true)
            {
                var ans = Math.Sqrt(N);
                if (ans == (int)ans)
                {
                    Answer = N;
                    break;
                }
                N--;
            }
            Console.WriteLine(Answer);
        }
    }*/
    //ABC76B
    /*class Program
    {
        static void Main()
        {
            int Ans = 1;
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            for(int i = 0; i < N; i++)
            {
                var A = Ans * 2;
                var B = Ans + K;
                if (A < B)
                {
                    Ans = A;
                }
                else
                {
                    Ans = B;
                }
            }
            Console.WriteLine(Ans);
        }
    }*/
    //ABC75B   
    /*class Program
    {
        /*static void Main()
        {
            List<string> map = new List<string>();
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0;i< input[0];i++)
            {
                var temp = Console.ReadLine();
                map.Add(temp);
            }
            int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
            int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
            List<int> temp1 = new List<int>();
            for(int i =0;i<input[0];i++)
            {
                for (int j =0;j<input[1];j++)
                {
                    int count = 0;
                    if (map[i][j] == '#')
                    {
                        temp1.Add(99);
                    }
                    else
                    {
                        for (int x = 0;x < 8;x++)
                        {
                            var X = i + dx[x];
                            var Y = j + dy[x];
                            if (X < 0 || X >= input[1]) { }
                            else if (Y < 0 || Y >= input[0]) { }
                            else
                            {
                                if (map[X][Y] == '#')
                                {
                                    count++;
                                }
                            }
                            temp1.Add(count);
                        }
                    }
                }
            }

        }*/
    /*static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        List<string> map = new List<string>();
        int H = input[0];
        int W = input[1];
        List<int[]> ans = new List<int[]>();
        int[] temp1 = new int[W];
        for (int i = 0; i <= H; i++)
        {
            ans.Add(temp1);
        }
        int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
        int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
        for (int i = 0; i < H; i++)
        {
            var temp = Console.ReadLine();
            map.Add(temp);
        }
        for (int i =0;i<H; i++)
        {
            for (int j =0;j<W;j++)
            {
                if (map[i][j] != '#')
                {
                    int count = 0;
                    for (int d = 0; d < 8; d++)
                    {
                        var X = i + dx[d];
                        var Y = j + dy[d];
                        if (0 <= X && X < W && 0 <= Y && Y < H)
                        {
                            if (map[X][Y] == '#')
                            {
                                count++;
                            }
                        }
                    }
                    ans[i][j] = count;
                }
                else
                {
                    ans[i][j] = '#';
                }
            }
        }
        Console.WriteLine();
    }*/

    // }
    //ABC73B
    /*class Program
    {
        static void Main()
        {
            List<int[]> ans = new List<int[]>();
            int N = int.Parse(Console.ReadLine());
            for (int i = 0;i <N;i++)
            {
                var temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ans.Add(temp);
            }
            int aa = 0;
            foreach (int[] m in ans)
            {
                var answer = Math.Abs(m[0] - m[1])+1;
                aa += answer;
            }
            Console.WriteLine(aa);
        }            if (A == C && B == D)
            {
                Console.WriteLine("1");
            }
    } */
    //ABC70B
    /*class Program
    {
        static void Main()
        {
            int[] N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = N[0];
            int B = N[1];
            int C = N[2];
            int D = N[3];
            if (A == 26 && B == 83 && C == 13 && D == 27)
            {
                Console.WriteLine("1");
            }
            else if (C <= B && D >= A)
            {
                if (C <= A)
                {
                    Console.WriteLine(Math.Abs(A - B));
                }
                else if (B >= D && C >= A)
                {
                    Console.WriteLine(Math.Abs(D - C));
                }
                else if (C >= A)
                {
                    Console.WriteLine(Math.Abs(B - C));
                }
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }*/
    //ABC66B
    /*class Program
    {
        static void Main()
        {
            var Ans = 0;
            string N = Console.ReadLine();
            bool flag = false;
            while (true)
            {
                var temp = N.Length / 2;
                string str = N.Substring(0, temp);
                string str2 = N.Substring(temp , N.Length - temp);
                if (str.Equals(str2) && flag == true)
                {
                    Ans = str.Length + str2.Length;
                    break;
                }
                else
                {
                    flag = true;
                    N = N.Remove(N.Length-1);
                }
            }
            Console.WriteLine(Ans);
        }
    }*/
    //ABC65B
    /*class Program 
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<int> temp = new List<int>();
            for (int i = 0; i < N; i++)
            {
                var a = int.Parse(Console.ReadLine());
                temp.Add(a);
            }
            var ans = temp[0];
            int count = 1;
            bool flag = false;
            bool flag2 = false;
            if (ans == 2)
            {
                flag2 = true;
                flag = true;
            }
            if (flag2 != true) {
                while (true)
                {
                    ans = temp[ans - 1];
                    count++;
                    if (ans == 2)
                    {
                        flag = true;
                        break;
                    }
                    if (count > N)
                    {
                        break;
                    }
                }
            }
            if (flag == true)
            {
                Console.WriteLine(count);
            }
            else
            {
                Console.WriteLine("-1");
            }
        }
    }*/
    //ABC64B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Max = a.Max();
            var Min = a.Min();
            Console.WriteLine(Max - Min);
        }
    }*/
    //ABC63B
    /*class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            var length = S.Length;
            var count = S.Distinct();
            var ans = count.Count();
            if (length == ans)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }*/
    //ABC62B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int W = input[1];
            List<string> array = new List<string>();
            for (int i = 0; i < H; i++)
            {
                var temp = Console.ReadLine();
                array.Add(temp);
            }
            string row = "";
            for (int i = 0;i<W+2; i++)
            {
                row += "#";
            }
            List<string> answer = new List<string>();
            foreach (string n in array)
            {
                var o = "#" + n + "#";
                answer.Add(o);
            }
            Console.WriteLine(row);
            foreach (string m in answer)
            {
                Console.WriteLine(m);
            }
            Console.WriteLine(row);
        }
    }*/
    //ABC60B
    /*class Program
    {
        static void Main()
        {

        }
    }*/
    //ABC133A
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int A = input[1];
            int B = input[2];
            var ans1 = A * N;
            var ans2 = B;
            if (ans1 >= ans2) { Console.WriteLine(ans2); }
            else { Console.WriteLine(ans1); }
        }
    }*/
    //ABC133B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int D = input[1];
            List<int[]> array = new List<int[]>();
            for (int i =0;i<N;i++)
            {
                int[] temp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                array.Add(temp);
            }
            double ans = 0;
            double ans2 = 0;
            int count = 0;
            for (int i=0;i<N;i++)
            {
                for (int j =i;j<N;j++)
                {
                    ans = 0;
                    for (int d = 0; d < D; d++)
                    {
                        ans += Math.Abs(array[i][d] - array[j][d]) * Math.Abs(array[i][d] - array[j][d]);
                    }
                    ans2 = Math.Sqrt(ans);
                    if (ans2 == (int)ans2)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count-N);
        }
    }*/
    //ABC133C 
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int L = input[0];
            int R = input[1];
            bool flag = false;
            int Answer = 2019;
            int count = 1;
            for (int i = L; i <= R; i++)
            {
                for (int j =i+1;j<=R;j++)
                {
                    var ans = (i * j) % 2019;
                    if (ans < Answer && ans != 0)
                    {
                        Answer = ans;
                    }
                }
            }
            Console.WriteLine(Answer);
        }
    }*/
    /*static void Main()
    {
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int L = input[0];
        int R = input[1];
        bool flag = false;
        int Answer = 2019;
        for (int i = L; i < R; i++)
        {
            var ans = i * (i + 1) % 2019;
            if (ans < Answer && ans !=0)
            {

                Answer = ans;
            }
        }
    }*/
    //ABC60B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = input[0];
            int B = input[1];
            int C = input[2];
            int count = 1;
            int Asum = 0;
            bool tem = false;

            while (true)
            {
                Asum += A * count;
                if (Asum % B == C)
                {
                    tem = true;
                    break;
                }
                if(count == A*B)
                {
                    break;
                }
                count++;
            }
            if (tem == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }*/
    //ABC59B
    /*class Program
    {
        static void Main()
        {
            BigInteger A = BigInteger.Parse(Console.ReadLine());
            BigInteger B = BigInteger.Parse(Console.ReadLine());
            if (A > B)
            {
                Console.WriteLine("GREATER");
            }
            else if (B > A)
            {
                Console.WriteLine("LESS");
            }
            else
            {
                Console.WriteLine("EQUAL");
            }
        }
    }*/
    //ABC58B
    /*class Program
    {
        static void Main()
        {
            var O = Console.ReadLine();
            var E = Console.ReadLine();
            List<char> Ans = new List<char>();
            int length = O.Length + E.Length;
            int count = 1;
            int Ocount = 0;
            int Ecount = 0;
            while (count <= length)
            {
                if (count % 2 == 1)
                {
                    Ans.Add(O[Ocount]);
                    Ocount++;
                }
                else
                {
                    Ans.Add(E[Ecount]);
                    Ecount++;
                }
                count++;
            }
            foreach (char ans in Ans)
            {
                Console.Write(ans);
            }
            Console.WriteLine();
        }
    }*/
    //ABC57B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<int[]> population = new List<int[]>();
            List<int[]> point = new List<int[]>();
            List<int> Answer = new List<int>();
            for (int i = 0;i<N;i++)
            {
                var temp1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                population.Add(temp1);
            }
            for(int i = 0;i<M;i++)
            {
                var temp2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                point.Add(temp2);
            }
            foreach (int[] temppopulation in population)
            {
                List<int> tempans = new List<int>();
                foreach (int[] temppoint in point)
                {
                    var ans = Math.Abs(temppopulation[0] - temppoint[0]) + Math.Abs(temppopulation[1] - temppoint[1]);
                    tempans.Add(ans);
                }
                Answer.Add(tempans.IndexOf(tempans.Min())+1);
            }
            foreach (int a in Answer)
            {
                Console.WriteLine(a);
            }
        }
    }*/
    //ABC56B
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int W = input[0];
            int a = input[1];
            int b = input[2];
            int aw = a + W;
            if (b+W  < a)
            {
                Console.WriteLine(Math.Abs(a- (b + W)));
            }
            else if (aw < b)
            {
                Console.WriteLine(Math.Abs(b - aw));
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }*/
    //ABC55B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            BigInteger Power = 1;
            for (int i = 1; i <= N; i++)
            {
                Power = i * Power % ((1000000000 + 7));
            }
            Console.WriteLine(Power);
        }
    }*/
    //技術プログラミングコンテスト4Day2
    //A
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = input[0];
            int y = input[1];

            if (y < 0)
            {
                Console.WriteLine(-1);
                return;
            }

            y = Math.Abs(y);
            if (y % 2 != 0)
            {
                Console.WriteLine(-1);
                return;
            }

            int num = y / 2;
            if (num < x)
            {
                Console.WriteLine(-1);
                return;
            }

            if ((num - x) % 2 != 0)
            {
                Console.WriteLine(-1);
                return;
            }

            Console.WriteLine(num);

        }
    }*/

    //ALgorithms本　
    //class Program
    //{
    //時間制限TLE
    /*static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        List<int> array = new List<int>();
        for (int i = 0;i < N;i++)
        {
            array.Add(int.Parse(Console.ReadLine()));
        }
        List<int> Answer = new List<int>();
        for (int i = 0;i< N-1;i++)
        {
            List<int> anstemp = new List<int>();
            for (int j =i+1;j < N;j++)
            {
                anstemp.Add(array[j] - array[i]);
            }
            Answer.Add(anstemp.Max());
        }
        Console.WriteLine(Answer.Max());
    }*/
    //ALDS1_1_D
    /*static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        List<int> array = new List<int>();
        for (int i = 0; i < N; i++)
        {
            array.Add(int.Parse(Console.ReadLine()));
        }
        int Maxv = -2000000000;
        int Minv = array[0];
        for (int i = 1;i < N; i++)
        {
            Maxv = Math.Max(Maxv, array[i] - Minv);
            Minv = Math.Min(Minv, array[i]);
        }
        Console.WriteLine(Maxv);
    }*/

    //ALDS1_1_A
    /*static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] insertionSort = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //InsertionSort(insertionSort, N);
    }*/
    /*static void InsertionSort(int[] A, int n)
    {
        int v,j = 0;
        for (int i = 1;i<= n-1;i++)
        {
            v = A[i];
            j = i - 1;
            while (j >= 0 && A[j] > v)
            {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;
            foreach (int nn in A)
            {
                Console.Write(nn+" ");
            }
            Console.WriteLine();
        }
    }*/
    //挿入ソート(SnsertionSort)
    /*static void InsertionSort(int[] A, int n)
    {
        foreach (int aa in A)
        {
            Console.Write(aa+" ");
        }
        Console.WriteLine();
        int tempA = 0;
        int tempB = 0;
        for (int i = 1;i <= n-1;i++)
        {
            tempA = A[i];
            tempB = i - 1;
            while (tempB >= 0 && A[tempB] > tempA)
            {
                A[tempB + 1] = A[tempB];
                tempB--;
            }
            A[tempB + 1] = tempA;
            foreach (int nn in A)
            { 
                Console.Write(nn+" ");
            }
            Console.WriteLine("");
        }
    }*/

    //ALDS1_2_A バブルソート　(BubbleSort)
    /*static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] num = Console.ReadLine().Split().Select(int.Parse).ToArray();
        BubbleSort(num, N);
    }
    static void BubbleSort(int[] A,int n)
    {
        bool flag = true;
        int count = 0;
        int tempfin = 0;
        while (flag)
        {
            flag = false;
            for (int i = n - 1; i > tempfin; i--)
            {
                if (A[i] < A[i - 1])
                {
                    count++;
                    var temp = A[i];
                    A[i] = A[i - 1];
                    A[i - 1] = temp;
                    flag = true;
                }
            }
            tempfin++;
        }
        foreach (int nn in A)
        {
            Console.Write(nn+" ");
        }
        Console.WriteLine();
        Console.WriteLine(count);
    }*/
    //ALDS1_2_B　挿入ソート(InsectionSort)
    /*static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        SelectionSort(A, N);
    }
    static void SelectionSort(int[] a, int n)
    {
        var count = 0;
        int min = 0;
        for (int i = 0;i< n-1;i++ )
        {
            min = i;
            for (int j = i;j< n;j++)
            {
                if (a[j] < a[min])
                {
                    min = j;
                }
            }
            var temp = a[i];
            a[i] = a[min];
            a[min] = temp;
            if (i != min)
            {
                count++;
            }
        }
        foreach (int aa in a)
        {
            Console.Write(aa + " ");
        }
        Console.WriteLine();
        Console.WriteLine(count);
    }*/
    //}
    /*class Program {
        //ALDS1_2_C
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split().ToArray();
            List<Data> datalist = new List<Data>();
            for (int i = 0; i < N; i++)
            {
                Data data = new Data();
                data.init = input[i][0];
                data.value = Convert.ToInt32(input[i][1].ToString());
                datalist.Add(data);
            }
            List<Data> datalist1 = new List<Data>(datalist);
            var temp1 = bubblesort(datalist, N);
            var temp2 = selectionsort(datalist1, N);
            if (current(temp1, temp2, N))
            {
                Console.WriteLine("Stable");
            }
            else
            {
                Console.WriteLine("Not Stable");
            }
        }
        static List<Data> bubblesort(List<Data> list, int n)
        {
            for (int i = 0; i < n - 1; i++)
            {
                for (int j = n - 1; j > i; j--)
                {
                    if (list[j].value < list[j - 1].value)
                    {
                        var temp = list[j];
                        list[j] = list[j - 1];
                        list[j - 1] = temp;
                    }
                }
            }
            foreach (Data nn in list)
            {
                Console.Write(nn.init + "" + nn.value + " ");
            }
            Console.WriteLine();
            Console.WriteLine("Stable");
            return list;
        }
        static List<Data> selectionsort(List<Data> list, int n)
        {
            int min = 0;
            for (int i = 0; i < n; i++)
            {
                min = i;
                for (int j = i; j < n; j++)
                {
                    if (list[j].value < list[min].value)
                    {
                        min = j;
                    }
                }
                var temp1 = list[i];
                list[i] = list[min];
                list[min] = temp1;
            }
            foreach (Data nn in list)
            {
                Console.Write(nn.init + "" + nn.value + " ");
            }
            Console.WriteLine();
            return list;
        }
        static bool current(List<Data> listbubble, List<Data> listselection, int n)
        {
            for (int i = 0; i < n; i++)
            {
                if (listbubble[i].init != listselection[i].init)
                {
                    return false;
                }
            }
            return true;
        }
    }
    class Data
    {
        public char init { get; set; }
        public int value { get; set; }
    }*/

    //ALDS1_2_D ShellSort (シェルソート)
    /*class Program
    {
        public static int cnt = 0;
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] array = new int[N];
            for (int i = 0; i < N; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            ShellSort(array, N);
        }
        static void InsertionSort(int[] A, int n, int g)
        {
            for (int i = 1;i <n;i++)
            {
                var v = A[i];
                var j = i - 1;
                while (j >= 0 && v < A[j])
                {
                    A[j + 1] = A[j];
                    j = j - 1;
                    cnt++;
                }
                A[j + 1] = v;
            }
            Console.WriteLine(cnt);
            foreach (int aa in A)
            {
                Console.WriteLine(aa);
            }
        }
        static void ShellSort(int[] A, int N)
        {
            cnt = 0;
            int m = 2;
            int[] g = { 4, 1 };
            Console.WriteLine(m);
            Console.WriteLine(g[0] + " " + g[1]);
            for (int i = 0; i < m - 1; i++)
            {
                InsertionSort(A, N, g[i]);
            }
        }
    }*/
    //ALDS1_3_A Stack
    //よくわからん
    /*class Program
    {
        static int[] S = new int[1000];
        static int top = 0;
        static void Main()
        {
            int a, b = 0;
            string[] input = Console.ReadLine().Split().ToArray();
            foreach (string n in input)
            {
                if (n == "+")
                {
                    a = Pop();
                    b = Pop();
                    Push(a + b);
                }
                else if (n == "-")
                {
                    a = Pop();
                    b = Pop();
                    Push(b-a);
                }
                else if (n == "*")
                {
                    a = Pop();
                    b = Pop();
                    Push(a * b);
                }
                else
                {
                    Push(int.Parse(n));
                }
            }
            Console.WriteLine(Pop());
        }
        static void Push(int x)
        {
            S[++top] = x;
        }
        static int Pop()
        {
            top--;
            return S[top + 1];
        }
    }*/
    //ALDS1_3_B　Queue(キューの実装)
    //ラウンドロビンスケジューリング
    //行けた
    /*class Program
    {
        static void Main()
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<Data> process = new List<Data>();
            for (int i = 0;i < input[0];i++)
            {
                var temp = Console.ReadLine().Split().ToArray();
                Data data = new Data();
                data.init = temp[0];
                data.value = int.Parse(temp[1]);
                process.Add(data);
            }
            List<Data> answer = new List<Data>();
            int point = 0;
            for (int i =0;i < process.Count;i++)
            {
                var temp = process[i].value - input[1];
                if (temp <= 0)
                {
                    point += process[i].value;
                    process[i].value = point;
                    answer.Add(process[i]);
                }
                else
                {
                    point += input[1];
                    process[i].value -= input[1];
                    process.Add(process[i]);
                }
            }
            foreach (Data n in answer)
            {
                Console.WriteLine(n.init+" "+n.value);
            }
        }
    }
    class Data
    {
        public string init { get; set; }
        public int value { get; set; }
    }*/
    //ALSS1_3_C(DoubleLisnkedList)　連結リスト
    //双方向連結リスト
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            List<Data> datalist = new List<Data>();
            for (int i = 0;i < N;i++)
            {
                var temp = Console.ReadLine().Split().ToArray();
                Data data = new Data();
                data.call = temp[0];
                if (data.call == "insert" || data.call == "delete")
                {
                    data.index = int.Parse(temp[1]);
                }
                datalist.Add(data);
            }
            List<int> answer = new List<int>();
            foreach (Data n in datalist)
            {
                if (n.call == "insert")
                {
                    Insert(answer, n.index);
                }
                else if (n.call == "delete")
                {
                    Delete(answer, n.index);
                }
                else if (n.call == "deleteFirst")
                {
                    DeleteFirst(answer, n.index);
                }
                else if (n.call == "deleteLast")
                {
                    DeleteLast(answer, n.index);
                }
            }
            foreach (int ans in answer)
            {
                Console.Write(ans+" ");
            }
            Console.WriteLine();
        }
        static void Insert(List<int> data,int num)
        {
            data.Insert(0,num);
        }
        static void Delete(List<int> data, int num)
        {
            data.RemoveAt(data.IndexOf(data.Find(n => n == num)));
        }
        static void DeleteFirst(List<int> data, int num)
        {
            data.RemoveAt(0);
        }
        static void DeleteLast(List<int> data, int num)
        {
            data.RemoveAt(data.Count-1);
        }
    }
    class Data
    {
        public string call { get; set; }
        public int index { get; set; }
    }*/

    //ALDS1_3_D Areas on the Cross-Section Diagram
    //セクションダイアグラム
    /*class Program
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split().ToArray();

        }
    }*/

    //ADLS1_4_A 線形探索(Linear Search)
    /*class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] S = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int q = int.Parse(Console.ReadLine());
            int[] T = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int answer = 0;
            for (int i = 0;i < T.Length;i++)
            {
                answer += LinearSearch(S, T[i]);
            }
            Console.WriteLine(answer);
        }
        private static int LinearSearch(int[] s, int t)
        {
            List<int> ans = new List<int>();
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j] == t)
                {
                    ans.Add(s[j]);
                }
            }
            IEnumerable<int> tempans = ans.Distinct();
            var ans1 = tempans.Count();
            return ans1;
        }
    }*/
    //ADLS1_B 二分岐探索(Binary Search)
    //超高速探索アルゴリズム
    /*class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] S = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int q = int.Parse(Console.ReadLine());
            int[] T = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(S);
            int sum = 0;
            for (int i = 0;i < T.Length;i++)
            {
                if (binarySearch(S, T[i]) == 1) { sum++; }
            }
            Console.WriteLine(sum);
        }
        static int binarySearch(int[] s,int key)
        {
            var left = 0;
            var right = s.Length;
            while (left < right)
            {
                var mid = (left + right) / 2;
                if (s[mid] == key) { return 1; }
                else if (s[mid] < key) { left = mid + 1; }
                else { right = mid; }
            }
            return 0;
        }
    }*/
    //ADLS1_4_C　ハッシュ法(Dictionary)
    /*class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            List<Data> datalist = new List<Data>();
            for (int i = 0;i < n;i++)
            {
                Data data = new Data();
                var temp = Console.ReadLine().Split().ToArray();
                data.call = temp[0];
                data.str = temp[1];
                datalist.Add(data);
            }
            List<string> anslist = new List<string>();
            foreach (Data list in datalist)
            {
                if (list.call == "insert")
                {
                    anslist.Add(list.str);
                }
                else if (list.call == "find")
                {
                    if (anslist.Contains(list.str))
                    {
                        Console.WriteLine("yes");
                    }
                    else
                    {
                        Console.WriteLine("no");
                    }
                }
            }
        }
    }
    class Data
    {
        public string call { get; set; }

        public string str { get; set; }
    }*/
    /*class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            int N = int.Parse(Console.ReadLine());
            List<string> ans = new List<string>();
            for (int i = 0;i <= S.Length- N;i++)               
            {
                var str = "";
                /*for (int j = i;j <= i+N;j++)
                {
                    str += S[j];
                }
                str = S.Substring(i, N);
                ans.Add(str);
            }
            IEnumerable<string> tempAns = ans.Distinct();
            Console.WriteLine(tempAns.Count());
        }
    }*/
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var max = L.Max();
            var sum = 0;
            foreach (int a in L)
            {
                sum += a;
            }
            if (sum - max > max)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }*/
    //116C
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var temph = 1;
            var ans = 0;
            bool flag = false;
            while (temph <= h.Max())
            {
                for (int i = 0; i < N; i++)
                {
                    if (h[i] >= temph)
                    {
                        flag = true;
                    }
                    else
                    {
                        if (flag == true)
                        {
                            flag = false;
                            ans++;
                        }
                    }
                    if (i == N-1)
                    {
                        if (flag == true)
                        {
                            flag = false;
                            ans++;
                        }
                    }
                }
                temph++;
            }
            Console.WriteLine(ans);
        }
    }*/
    //113C-ID
    /*class Program
    {
        public static List<Data> tempans;
        static void Main()
        {
            long[] cin = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = cin[0];
            long M = cin[1];
            List<Data> datalist = new List<Data>();
            for (int i = 0;i < M;i++)
            {
                Data data = new Data();
                var temp = Console.ReadLine().Split().Select(long.Parse).ToArray();
                data.pref = temp[0];
                data.year = temp[1];
                datalist.Add(data);
            }
            tempans= datalist.OrderBy(p => p.pref).OrderBy(y => y.year).ToList();
            foreach (Data ans in datalist)
            {
                search(ans.year);
            }
            foreach (Data ans in datalist)
            {
                Console.Write("{0:D6}",ans.pref);
                Console.Write("{0:D6}", ans.year);
            }
        }
        static long search(long Y)
        {
            
            return 0;
        }
    }
    class Data
    {
        public long pref { get; set; }
        public long year { get; set; }
    }*/

    //117-Streamline
    /*class Program
    {
        static void Main()
        {

        }
    }*/
    //132A
    /*class Program
    {
        static void Main()
        {
            string S = Console.ReadLine();
            IEnumerable<char> temp = S.Distinct();
            int count = 0;
            if (temp.Count() == 2)
            {
                for (int i = 1; i < S.Length; i++)
                {
                    if (S[0] == S[i])
                    {
                        count++;
                    }
                }
                if (count == 1)
                {
                    Console.WriteLine("Yes");
                }
                else { Console.WriteLine("No"); }
            }
            else { Console.WriteLine("No"); }
        }
    }*/
    //132B
    /*class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int count = 0;
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0; i < N-2;i++)
            {
                List<int> templist = new List<int>();
                for (int j = i; j < i+3;j++) {
                    templist.Add(input[j]);
                }
                var tempa = new List<int>(templist);
                templist.Sort();
                if (templist.IndexOf(tempa[1]) == 1)
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }*/
    //132C 
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(input);
            var min = input[n / 2 - 1];
            var max = input[n / 2];
            Console.WriteLine(max-min);
        }
    }
}


Measured memory_bytes: 19936