#region imports
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

#endregion

namespace CodeForces
{
    class Problem
    {
        const bool IsContest = true;

        private bool _interrupt;
        private int[] _perm;
        private bool[] _used;
        int _n;
        int _m;

        private struct Perm
        {
            public string st;
            public long fp;
        }

        private List<Perm> ls;
        private void Solve()
        {
            _n = _.NextInt();
            _m = _.NextInt();
            ls = new List<Perm>();
            _perm = new int[_n];
            _interrupt = false;
            _used = new bool[_n + 1];
            BackTrack(0);
            var max = ls.Select(x => x.fp).Max();
            var ans = ls.Where(x => x.fp == max).ElementAt(_m - 1).st;
            _.WriteLine(ans);
        }

        private long Fp()
        {
            var sum = 0L;
            for (var i = 0; i < _n; i++)
                for (var j = i; j < _n; j++)
                {
                    var min = int.MaxValue;
                    for (var k = i; k <= j; k++)
                    {
                        min = Math.Min(min, _perm[k]);
                    }
                    sum += min;
                }
            return sum;
        }

        private void BackTrack(int indexToFill)
        {
            if (indexToFill == _n)
            {
                Release();
                return;
            }
            for (var i = 1; i <= _n; i++)
            {
                if (_used[i]) continue;
                _perm[indexToFill] = i;
                _used[i] = true;
                BackTrack(indexToFill + 1);
                if (_interrupt) return;
                _used[i] = false;
            }
        }

        private void Release()
        {
            ls.Add(new Perm { st = string.Join(" ", _perm), fp = Fp() });
        }

        #region shit
        private readonly InOut _ = new InOut(IsContest);

        static void Main(string[] args)
        {
            var p = new Problem();
            p.Solve();
            p._.Close();
        }
    }
    class InOut
    {
        private const string InputFile = "input.txt";
        private const string OutputFile = "output.txt";
        public StreamWriter Cout { get; private set; }
        public StreamReader Cin { get; private set; }
        private void SetConsoleIo()
        {
            Cin = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
            Cout = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
        }
        private void SetFileIo(string inputFile, string outputFile) { Cin = new StreamReader(inputFile); Cout = new StreamWriter(outputFile); }
        public InOut() { SetConsoleIo(); }
        public InOut(string inputFile, string outputFile) { SetFileIo(inputFile, outputFile); }
        public InOut(bool isContest) { if (isContest) SetConsoleIo(); else SetFileIo(InputFile, OutputFile); }
        public void WriteLine(object x) { Cout.WriteLine(x); }
        public void Close() { Cin.Close(); Cout.Close(); }
        public void WriteLine(string format, params object[] args) { Cout.WriteLine(format, args); }
        private int _pos;
        private string[] _tokens;

        private string[] NextStringArray() { return Cin.ReadLine().Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); }
        public string NextToken()
        {
            while (_tokens == null || _pos == _tokens.Length)
            {
                // ReSharper disable once PossibleNullReferenceException
                _tokens = NextStringArray();
                _pos = 0;
            }
            return _tokens[_pos++];
        }
        public int NextInt() { return int.Parse(NextToken()); }
        public long NextLong() { return long.Parse(NextToken()); }
        public double NextDouble() { return double.Parse(NextToken(), CultureInfo.InvariantCulture); }
        public int[] NextIntArray() { return NextStringArray().Select(int.Parse).ToArray(); }
        public byte[] NextByteArray() { return NextStringArray().Select(byte.Parse).ToArray(); }
        public long[] NextLongArray() { return NextStringArray().Select(long.Parse).ToArray(); }
        #endregion
    }
}


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

namespace prB2 {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter("output");
        private static readonly StreamReader reader = new StreamReader("input");
#endif
        static void Main(string[] args) {
            string[] ss = reader.ReadLine().Split(' ');
            int n = int.Parse(ss[0]);
            ulong m = ulong.Parse(ss[1]);
            ulong[] st = new ulong[51];
            st[0] = 1;
            for(int i = 1; i < 51; i++) {
                st[i] = st[i - 1] * 2;
            }
            int q = 1;
            HashSet<int> set = new HashSet<int>();
            for(int i = 0; i < n; i++) {
                ulong p = 0;
                while(q < n && m > p + st[n - 1 - q]) {
                    p += st[n - 1 - q];
                    q++;
                }
                writer.Write(q);
                writer.Write(' ');
                set.Add(q);
                m -= p;
                q++;
                if(q >= n)
                    break;
            }
            for(int i = n; i >= 1; i--) {
                if(!set.Contains(i)) {
                    writer.Write(i);
                    writer.Write(' ');
                }
            }
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;

namespace RM_R2015_B1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            double m = double.Parse(s[1]);
            string ans = "1";
            double[] a = new double[n + 1];

            int i = n;
            while (i > 1)
            {
                m = m / 2;
                a[i] = m;
                m = Math.Ceiling(m);
                i--;
            }

            int k = 1;
            for (i = 2; i <= n; i++)
            {
                if (a[i] == Math.Ceiling(a[i]))
                {
                    int ind = ans.IndexOf(k.ToString());
                    k++;
                    if (ind == 0) ans = k.ToString() + ans;
                    else ans = ans.Substring(0, ind) + k.ToString() + ans.Substring(ind, ans.Length - ind);
                }
                else
                {
                    int ind = ans.IndexOf(k.ToString());
                    k++;
                    if (ind == ans.Length - 1) ans = ans + k.ToString();
                    else ans = ans.Substring(0, ind + 1) + k.ToString() + ans.Substring(ind + 1, ans.Length - ind - 1);
                }
            }
            for (i = 0; i < n; i++)
            {
                Console.Write("{0} ", ans[i]);
            }
        }
    }
}


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

namespace TaskB
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                //s = @"6 2".Split(cs, StringSplitOptions.RemoveEmptyEntries);
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return s[i++];
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }
        }
        static void Main(string[] args)
        {
            Scanner sc = new Scanner();
            int n = sc.nextInt();
            int m = sc.nextInt();

            int[] arr = new int[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = i + 1;
            }
            if (m == 1)
            {
                PrintArr(arr);
                return;
            }
            int max = SumX(arr);
            int count = 1;
            while (NextPermutation(arr))
            {
                int num = SumX(arr);
                if (num >= max)
                {
                    count++;
                    if (count == m)
                    {
                        PrintArr(arr);
                        return;
                    }
                    max = num;
                }
            }
        }

        private static void PrintArr(int[] arr)
        {
            StringBuilder sb = new StringBuilder(arr.Length * 2 - 1);
            for (int i = 0; i < arr.Length; i++)
            {
                sb.Append(arr[i]);
                if (i != arr.Length - 1)
                {
                    sb.Append(" ");
                }

            }
            Console.WriteLine(sb);
        }

        static int SumX(int[] arr)
        {
            int sum = 0;
            for (int i = 0; i < arr.Length; i++)
            {
                for (int j = i; j < arr.Length; j++)
                {
                    sum += arr.Skip(i).Take(j - i + 1).Min();
                }
            }
            return sum;
        }

        private static bool NextPermutation(int[] numList)
        {
            var largestIndex = -1;
            for (var i = numList.Length - 2; i >= 0; i--)
            {
                if (numList[i] < numList[i + 1])
                {
                    largestIndex = i;
                    break;
                }
            }

            if (largestIndex < 0) return false;

            var largestIndex2 = -1;
            for (var i = numList.Length - 1; i >= 0; i--)
            {
                if (numList[largestIndex] < numList[i])
                {
                    largestIndex2 = i;
                    break;
                }
            }

            var tmp = numList[largestIndex];
            numList[largestIndex] = numList[largestIndex2];
            numList[largestIndex2] = tmp;

            for (int i = largestIndex + 1, j = numList.Length - 1; i < j; i++, j--)
            {
                tmp = numList[i];
                numList[i] = numList[j];
                numList[j] = tmp;
            }

            return true;
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {

        public void Solve()
        {

            var n = sc.Integer();
            var m = sc.Long();
            var a = new int[n];
            var rank = n - 2;
            var nibeki = new long[60];
            nibeki[0] = 1;
            for (int i = 1; i < 60; i++)
                nibeki[i] = nibeki[i - 1] * 2;
            var used = new bool[n + 1];
            var down = false;
            for (int i = 0; i < n; i++)
            {
                var p = 0;
                for (int j = rank; j >= 0; j--)
                {
                    if (nibeki[j] >= m) { rank = Math.Max(0, j - 1); break; }
                    m -= nibeki[j];
                    p++;
                }
                if (down)
                {
                    for (int j = n, t = 0; j >= 1; j--)
                        if (used[j]) continue;
                        else
                        {
                            if (i > 0 && a[i - 1] < j) continue;
                            if (t == p)
                            {
                                a[i] = j;
                                used[j] = true;
                                if (j == n) down = true;
                                break;
                            }
                            t++;
                        }
                }
                else
                {
                    for (int j = 1, t = 0; j <= n; j++)
                        if (used[j]) continue;
                        else
                        {
                            if (i > 0 && a[i - 1] > j) continue;
                            if (t == p)
                            {

                                a[i] = j;
                                used[j] = true;
                                if (j == n) down = true;
                                break;
                            }
                            t++;
                        }
                }

            }
            IO.Printer.Out.WriteLine(a.AsJoinedString());
        }

        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 < b);            return (char)b; }

        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion


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

// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        long m = ReadLong() - 1;
        int l = 0, r = n - 1;
        var a = new int[n];
        for (int i = n - 2, j = 1; i >= 0; i--, j++)
        {
            if ((m >> i & 1) == 1)
                a[r--] = j;
            else
                a[l++] = j;
        }
        a[l] = n;
        WriteArray(a);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;

    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("game.in");
        //writer = new StreamWriter("game.out");
#endif
        try
        {
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 256);
            thread.Start();
            thread.Join();
            //new Solver().Solve();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            Console.WriteLine(ex);
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write

    private static Queue<string> currentLineTokens = new Queue<string>();

    private static string[] ReadAndSplitLine()
    {
        return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public static string ReadToken()
    {
        while (currentLineTokens.Count == 0)
            currentLineTokens = new Queue<string>(ReadAndSplitLine());
        return currentLineTokens.Dequeue();
    }

    public static int ReadInt()
    {
        return int.Parse(ReadToken());
    }

    public static long ReadLong()
    {
        return long.Parse(ReadToken());
    }

    public static double ReadDouble()
    {
        return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
    }

    public static int[] ReadIntArray()
    {
        return ReadAndSplitLine().Select(int.Parse).ToArray();
    }

    public static long[] ReadLongArray()
    {
        return ReadAndSplitLine().Select(long.Parse).ToArray();
    }

    public static double[] ReadDoubleArray()
    {
        return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
    }

    public static int[][] ReadIntMatrix(int numberOfRows)
    {
        int[][] matrix = new int[numberOfRows][];
        for (int i = 0; i < numberOfRows; i++)
            matrix[i] = ReadIntArray();
        return matrix;
    }

    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows);
        int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++)
        {
            ret[i] = new int[numberOfRows];
            for (int j = 0; j < numberOfRows; j++)
                ret[i][j] = matrix[j][i];
        }
        return ret;
    }

    public static string[] ReadLines(int quantity)
    {
        string[] lines = new string[quantity];
        for (int i = 0; i < quantity; i++)
            lines[i] = reader.ReadLine().Trim();
        return lines;
    }

    public static void WriteArray<T>(IEnumerable<T> array)
    {
        writer.WriteLine(string.Join(" ", array));
    }

    public static void Write(params object[] array)
    {
        WriteArray(array);
    }

    public static void WriteLines<T>(IEnumerable<T> array)
    {
        foreach (var a in array)
            writer.WriteLine(a);
    }

    #endregion
}


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

namespace Permutations
{
    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 = (int)Next();
            long m = Next() - 1;

            var nn = new int[2*n + 1];
            nn[n] = n;
            int l = n;
            int r = n;

            for (int i = n - 1; i > 0; i--)
            {
                if ((m & 1) == 1)
                {
                    nn[++r] = i;
                }
                else
                {
                    nn[--l] = i;
                }
                m >>= 1;
            }

            for (int i = l; i <= r; i++)
            {
                writer.Write(nn[i]);
                writer.Write(' ');
            }
            writer.Flush();
        }

        private static long Next()
        {
            int c;
            long 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;

namespace Permutations
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var strs = str.Split(' '); // Divide a string de entrada
            int n = 0;
            long m = 0;
            int.TryParse(strs[0], out n); // Tenta converter a entrada na posição 0
            long.TryParse(strs[1], out m); // Tenta converter a entrada na posição 1
            --m;

            int[] array = new int[n];

            var tempm = m;
            for (int i = 0; i < n; i++)
            {
                array[i] = (int)(tempm % 2);
                tempm /= 2;
            }

            for (int i = 0; i < n - 1; i ++)
            {
                if (array[n - 1 - i - 1] == 0)
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }
                else
                {
                    // Não faz nada
                }

            }

            // if (p2 > 0)
            {
               Console.Write(n - 1 + 1 );
               Console.Write(" ");
            }

            for (int i = n - 2; i >= 0; i--)
            {
                if (array[n - 1 - i -1] == 0)
                {
                    // Não faz nada
                }
                else
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }

            }
            Console.WriteLine("");
        }
    }
}


using System;

namespace RM_R2015_B1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            double m = double.Parse(s[1]);
            string ans = "1";
            double[] a = new double[n + 1];

            int i = n;
            while (i > 1)
            {
                m = m / 2;
                a[i] = m;
                m = Math.Ceiling(m);
                i--;
            }

            int k = 1;
            for (i = 2; i <= n; i++)
            {
                if (a[i] == Math.Ceiling(a[i]))
                {
                    int ind = ans.IndexOf(k.ToString());
                    k++;
                    if (ind == 0) ans = k.ToString() + " " +ans;
                    else ans = ans.Substring(0, ind) +" "+ k.ToString() + " " + ans.Substring(ind, ans.Length - ind);
                }
                else
                {
                    int ind = ans.IndexOf(k.ToString());
                    k++;
                    if (ind == ans.Length - 1) ans = ans + " " + k.ToString();
                    else ans = ans.Substring(0, ind + 1) +" "+ k.ToString() +" "+ ans.Substring(ind + 1, ans.Length - ind - 1);
                }
            }
            while (ans.IndexOf("  ") != -1) ans = ans.Remove(ans.IndexOf("  "),1);
            s = ans.Split(' ');
            for (i = 0; i < n; i++)
            {
                Console.Write("{0} ", s[i]);
            }
        }
    }
}


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

namespace RocketB
{
    class Program
    {

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var strs = str.Split(' ');
            int n = 0;
            int m = 0;
            int.TryParse(strs[0], out n);
            int.TryParse(strs[1], out m);
            --m;

            int[] array = new int[n];

            var tempm = m;
            for (int i = 0; i < n; i++)
            {
                array[i] = tempm % 2;
                tempm /= 2;
            }

            for (int i = 0; i < n - 1; i ++)
            {
                if (array[n - 1 - i - 1] == 0)
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }
                else
                {
                    //Console.Write(i + 1 );
                    //Console.Write(" ");
                }

            }

           // if (p2 > 0)
            {
                Console.Write(n - 1 + 1 );
                Console.Write(" ");
            }

            for (int i = n - 2; i >= 0; i--)
            {
                if (array[n - 1 - i -1] == 0)
                {
                    //Console.Write(i + 1);
                    //Console.Write(" ");
                }
                else
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }

            }
            Console.WriteLine("");

        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
namespace Program
{
    public class Solver
    {

        public void Solve()
        {

            var n = sc.Integer();
            long m = sc.Integer();
            var a = new int[n];
            var rank = n - 2;
            var nibeki = new long[60];
            nibeki[0] = 1;
            for (int i = 1; i < 60; i++)
                nibeki[i] = nibeki[i - 1] * 2;
            var used = new bool[n + 1];
            var down = false;
            for (int i = 0; i < n; i++)
            {
                var p = 0;
                for (int j = rank; j >= 0; j--)
                {
                    if (nibeki[j] >= m) { rank = Math.Max(0,j-1); break; }
                    m -= nibeki[j];
                    p++;
                }
                if (down)
                {
                    for (int j = n, t = 0; j >= 1; j--)
                        if (used[j]) continue;
                        else
                        {
                            if (i > 0 && a[i - 1] < j) continue;
                            if (t == p)
                            {
                                a[i] = j;
                                used[j] = true;
                                if (j == n) down = true;
                                break;
                            }
                            t++;
                        }
                }
                else
                {
                    for (int j = 1, t = 0; j <= n; j++)
                        if (used[j]) continue;
                        else
                        {
                            if (i > 0 && a[i - 1] > j) continue;
                            if (t == p)
                            {

                                a[i] = j;
                                used[j] = true;
                                if (j == n) down = true;
                                break;
                            }
                            t++;
                        }
                }

            }
            IO.Printer.Out.WriteLine(a.AsJoinedString());

        }

        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());
        static T[] Enumerate<T>(int n, Func<int, T> f) { var a = new T[n]; for (int i = 0; i < n; ++i) a[i] = f(i); return a; }

    }

}

#region Ex
namespace Program.IO
{
    using System.IO;
    using System.Text;
    using System.Globalization;
    public class Printer : StreamWriter
    {
        static Printer() { Out = new Printer(Console.OpenStandardOutput()) { AutoFlush = false }; }
        public static Printer Out { get; set; }
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(System.IO.Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
        public Printer(System.IO.Stream stream, Encoding encoding) : base(stream, encoding) { }
        public void Write<T>(string format, IEnumerable<T> source) { base.Write(format, source.OfType<object>().ToArray()); }
        public void WriteLine<T>(string format, IEnumerable<T> source) { base.WriteLine(format, source.OfType<object>().ToArray()); }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) return 0;
            if (ptr >= len) { ptr = 0; if ((len = str.Read(buf, 0, 1024)) <= 0) { isEof = true; return 0; } }
            return buf[ptr++];
        }
        public char Char() { byte b = 0; do b = read(); while (b < 33 || 126 = 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            if (isEof) return long.MinValue;
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (isEof) ? int.MinValue : (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
        private T[] enumerate<T>(int n, Func<T> f)
        {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f();
            return a;
        }

        public char[] Char(int n) { return enumerate(n, Char); }
        public string[] Scan(int n) { return enumerate(n, Scan); }
        public double[] Double(int n) { return enumerate(n, Double); }
        public int[] Integer(int n) { return enumerate(n, Integer); }
        public long[] Long(int n) { return enumerate(n, Long); }
    }
}
static class Ex
{
    static public string AsString(this IEnumerable<char> ie) { return new string(System.Linq.Enumerable.ToArray(ie)); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") { return string.Join(st, ie); }
    static public void Main()
    {
        var solver = new Program.Solver();
        solver.Solve();
        Program.IO.Printer.Out.Flush();
    }
}
#endregion
#region SegTree
[System.Diagnostics.DebuggerDisplay("Data={ToString()}")]
public class SegmentTree
{
    const long Max = 1L << 60;
    int n;
    long[] data;
    public SegmentTree(int size)
    {
        n = 1;
        while (n < size)
            n <<= 1;
        data = new long[n << 1];
        for (int i = 0; i < data.Length; i++)
            data[i] = Max;
    }

    // turn kth index value into v
    public void Update(int k, long v)
    {
        k += n;
        data[k] = v;
        k >>= 1;
        while (k > 0)
        {
            data[k] = Math.Min(data[k << 1], data[(k << 1) + 1]);
            k >>= 1;
        }

    }
    public long Query(int a, int b) { return Query(a, b, 1, 0, n); }
    private long Query(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
            return Max;
        if (a <= l && r <= b)
            return data[k];
        else
        {
            var vl = Query(a, b, k << 1, l, (l + r) >> 1);
            var vr = Query(a, b, (k << 1) + 1, (l + r) >> 1, r);
            return Math.Min(vl, vr);
        }
    }

    /*
    ///Data[i]>
    public long this[int i] { get { return data[i + n]; } }
    ///Minimum[a,b)>
    public long this[int l, int r] { get { return Query(l, r, 1, 0, n); } }
    public override string ToString()
    {
        return string.Join(",", Enumerable.Range(0, n).Select(i => this[i]).Where(v => v != Max));
    }
    public string Visualize()
    {
        var sb = new System.Text.StringBuilder();
        var k = 2;
        var len = n << 1;
        for (int i = 1; i < len; i++)
        {
            if (data[i] != Max) sb.Append(data[i]);
            else sb.Append('-');
            if (i < k - 1) sb.Append(',');
            else if (i < len - 1)
            {
                sb.AppendLine();
                k <<= 1;
            }
        }
        return sb.ToString();
    }
     //*/
}
#endregion

#region RSBT
public class RandomizedBinarySearchTree<T>
{
    Node root;
    Comparison<T> compare;
    public RandomizedBinarySearchTree(Comparison<T> cmp) { compare = cmp; }
    public RandomizedBinarySearchTree() : this(Comparer<T>.Default.Compare) { }
    public void Insert(T v, int k)
    {
        var s = Node.Split(root, k);
        root = Node.Merge(Node.Merge(s.lst, new Node(v)), s.rst);
    }
    public void RemoveAt(int k)
    {
        var s = Node.Split(root, k);
        root = Node.Merge(s.lst, Node.Split(s.rst, 1).rst);
    }
    public void Merge(RandomizedBinarySearchTree<T> other)
    {
        root = Node.Merge(root, other.root);
    }
    public RandomizedBinarySearchTree<T> Split(int k)
    {
        var s = Node.Split(root, k);
        root = s.lst;
        return new RandomizedBinarySearchTree<T>(compare) { root = s.rst };
    }

    public T this[int k] { get { return Node.Find(root, k); } }
    public void Add(T v)
    {
        Insert(v, LowerBound(v));
    }
    public void Remove(T v)
    {
        if (Count(v) == 0) return;
        RemoveAt(LowerBound(v));
    }
    public int Count(T v)
    {
        return UpperBound(v) - LowerBound(v);
    }
    public int LowerBound(T v)
    {
        return Node.LowerBound(root, v, compare);
    }
    public int UpperBound(T v)
    {
        return Node.UpperBound(root, v, compare);
    }

    private class XORShift
    {
        public XORShift() { }
        public XORShift(uint seed) { w = seed; }

        uint x = 123456789, y = 362436069, z = 521288629, w = 88675123;
        uint t;
        public long Next()
        {
            t = (x ^ (x << 11)); x = y; y = z; z = w;
            return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
        }

    }

    private class Node
    {
        static XORShift rand = new XORShift();
        public readonly T val;
        public Node lst, rst;
        public int cnt;
        public Node(T v) { val = v; cnt = 1; }
        private Node(Node l, Node r) { lst = l; rst = r; }
        private void push()
        {

        }
        public override string ToString() { return string.Format("count:{0} value:{1}", Count(this), val); }
        static int Count(Node t) { return t == null ? 0 : t.cnt; }
        static public Node Update(Node t)
        {
            t.cnt = 1 + Count(t.lst) + Count(t.rst);
            return t;
        }

        static public Node Merge(Node l, Node r)
        {
            if (l == null || r == null)
                return l == null ? r : l;
            l.push(); r.push();

            if (rand.Next() % (l.cnt + r.cnt) < l.cnt)
            {
                l.rst = Merge(l.rst, r);
                return Update(l);
            }
            else
            {
                r.lst = Merge(l, r.lst);
                return Update(r);
            }

        }
        static public Node Split(Node t, int k)
        {
            if (t == null) return new Node(null, null);
            t.push();
            if (k <= Count(t.lst))
            {
                var s = Split(t.lst, k);
                t.lst = s.rst;
                return new Node(s.lst, Update(t));
            }
            else
            {
                var s = Split(t.rst, k - Count(t.lst) - 1);
                t.rst = s.lst;
                return new Node(Update(t), s.rst);
            }
        }
        static public T Find(Node t, int k)
        {
            if (Count(t) < k) throw new IndexOutOfRangeException();
            if (k == Count(t.lst)) return t.val;
            if (k < Count(t.lst)) return Find(t.lst, k);
            else return Find(t.rst, k - (Count(t.lst) + 1));
        }
        static public int LowerBound(Node t, T v, Comparison<T> compare)
        {
            if (Count(t) == 0) return 0;
            if (compare(v, t.val) <= 0) return LowerBound(t.lst, v, compare);
            return Count(t.lst) + 1 + LowerBound(t.rst, v, compare);
        }
        static public int UpperBound(Node t, T v, Comparison<T> compare)
        {
            if (Count(t) == 0) return 0;
            if (compare(t.val, v) <= 0) return Count(t.lst) + 1 + UpperBound(t.rst, v, compare);
            return UpperBound(t.lst, v, compare);
        }

    }
}
#endregion

#region BinarySearch for Array
static public partial class Algorithm
{

    static private int binarySearch<T>(this T[] a, int idx, int len, T v, Comparison<T> cmp, bool islb)
    {
        int l = idx;
        int h = idx + len - 1;
        while (l <= h)
        {
            int i = l + ((h - l) >> 1);
            int ord;
            if (a[i] == null || v == null) return -1;
            else ord = cmp(a[i], v);
            if (ord < 0) l = i + 1;
            else if (ord == 0)
            {
                if (!islb) l = i + 1;
                else h = i - 1;
            }
            else h = i - 1;
        }

        return l;
    }
    static public int UpperBound<T>(this T[] a, int idx, int len, T v, Comparison<T> cmp) { return binarySearch(a, idx, len, v, cmp, false); }
    static public int UpperBound<T>(this T[] a, int idx, int len, T v) where T : IComparable<T> { return UpperBound(a, idx, len, v, Comparer<T>.Default.Compare); }
    static public int UpperBound<T>(this T[] a, T v) where T : IComparable<T> { return UpperBound(a, 0, a.Length, v, Comparer<T>.Default.Compare); }
    static public int UpperBound<T>(this T[] a, T v, IComparer<T> cmp) { return UpperBound(a, 0, a.Length, v, cmp.Compare); }
    static public int UpperBound<T>(this T[] a, T v, Comparison<T> cmp) { return UpperBound(a, 0, a.Length, v, cmp); }

    static public int LowerBound<T>(this T[] a, int idx, int len, T value, Comparison<T> cmp) { return binarySearch(a, idx, len, value, cmp, true); }
    static public int LowerBound<T>(this T[] a, int idx, int len, T value) where T : IComparable<T> { return LowerBound(a, idx, len, value, Comparer<T>.Default.Compare); }
    static public int LowerBound<T>(this T[] a, T val) where T : IComparable<T> { return LowerBound(a, 0, a.Length, val, Comparer<T>.Default.Compare); }
    static public int LowerBound<T>(this T[] a, T val, IComparer<T> cmp) { return LowerBound(a, 0, a.Length, val, cmp.Compare); }
    static public int LowerBound<T>(this T[] a, T v, Comparison<T> cmp) { return LowerBound(a, 0, a.Length, v, cmp); }
}
#endregion

#region next_permutation
static public partial class MathEx
{

    static public bool NextPermutation<T>(T[] array, int first, int last) where T : IComparable<T>
    {
        if (first == last)
            return false;
        var i = last;
        if (--i == first)
            return false;
        while (true)
        {
            var ii = i--;
            if (array[i].CompareTo(array[ii]) < 0)
            {
                var j = last;
                while (array[i].CompareTo(array[--j]) >= 0) { }
                var temp = array[i];
                array[i] = array[j];
                array[j] = temp;
                Array.Reverse(array, ii, last - ii);
                return true;
            }
            if (i == first)
            {
                Array.Reverse(array, first, last - first);
                return false;
            }
        }
    }

}
#endregion


using System;

namespace Permutations
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var strs = str.Split(' '); // Divide a string de entrada
            int n = 0;
            long m = 0;
            int.TryParse(strs[0], out n); // Tenta converter a entrada na posição 0
            long.TryParse(strs[1], out m); // Tenta converter a entrada na posição 1
            --m;

            int[] array = new int[n];

            var tempm = m;
            for (int i = 0; i < n; i++)
            {
                array[i] = (int)(tempm % 2);
                tempm /= 2;
            }

            for (int i = 0; i < n - 1; i ++)
            {
                if (array[n - 1 - i - 1] == 0)
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }
                else
                {
                    //Console.Write(i + 1 );
                    //Console.Write(" ");
                }

            }

            // if (p2 > 0)
            // {
            //   Console.Write(n - 1 + 1 );
            //   Console.Write(" ");
            // }

            for (int i = n - 2; i >= 0; i--)
            {
                if (array[n - 1 - i -1] == 0)
                {
                    // Não faz nada
                }
                else
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }

            }
            Console.WriteLine("");
        }
    }
}


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

namespace RocketB
{
    class Program
    {

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var strs = str.Split(' ');
            int n = 0;
            long m = 0;
            int.TryParse(strs[0], out n);
            long.TryParse(strs[1], out m);
            --m;

            int[] array = new int[n];

            var tempm = m;
            for (int i = 0; i < n; i++)
            {
                array[i] = tempm % 2;
                tempm /= 2;
            }

            for (int i = 0; i < n - 1; i ++)
            {
                if (array[n - 1 - i - 1] == 0)
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }
                else
                {
                    //Console.Write(i + 1 );
                    //Console.Write(" ");
                }

            }

           // if (p2 > 0)
            {
                Console.Write(n - 1 + 1 );
                Console.Write(" ");
            }

            for (int i = n - 2; i >= 0; i--)
            {
                if (array[n - 1 - i -1] == 0)
                {
                    //Console.Write(i + 1);
                    //Console.Write(" ");
                }
                else
                {
                    Console.Write(i + 1);
                    Console.Write(" ");
                }

            }
            Console.WriteLine("");

        }
    }
}


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

namespace International_Olympiad
{
    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 = int.Parse(reader.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string s = reader.ReadLine().Substring(4);
                long t = long.Parse(s);

                long pow = 10, f = 0;

                for (int k = 1; k < s.Length; k++)
                {
                    f += pow;
                    pow *= 10;
                }

                while (t < 1989 + f)
                {
                    t += pow;
                }

                writer.WriteLine(t);
            }

            writer.Flush();
        }
    }
}


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

namespace International_Olympiad
{
    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 = int.Parse(reader.ReadLine());

            var h = new HashSet<long>();

            for (int i = 0; i < n; i++)
            {
                string s = reader.ReadLine().Substring(4);
                long t = long.Parse(s);

                long start, pow;
                if (t == 9)
                {
                    start = 198;
                    pow = 10;
                }
                else if (t < 9)
                {
                    start = 199;
                    pow = 10;
                }
                else if (t >= 89 && t < 100)
                {
                    start = 19;
                    pow = 100;
                }
                else if (t < 100)
                {
                    start = 20;
                    pow = 100;
                }
                else if (t >= 989 && t < 1000)
                {
                    start = 1;
                    pow = 1000;
                }
                else if (t < 1000)
                {
                    start = 2;
                    pow = 1000;
                }
                else if (t >= 1989 && t < 10000)
                {
                    start = 0;
                    pow = 10000;
                }
                else if (t < 10000)
                {
                    start = 1;
                    pow = 10000;
                }
                else
                {
                    start = 0;
                    pow = Pow(10, s.Length + 1);
                }

                while (true)
                {
                    long y = start*pow + t;
                    if (h.Contains(y))
                        start++;
                    else
                    {
                        h.Add(y);
                        writer.WriteLine(y);
                        break;
                    }
                }
            }

            writer.Flush();
        }

        private static long Pow(long a, int k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a);
                }
                a = (a*a);
                k >>= 1;
            }
            return r;
        }
    }
}


//#define EXTENDSTACKSIZE

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

namespace CF
{
    internal class Program
    {
        private const int stackSize = 64 * 1024 * 1024;

        private static void Run()
        {
            using (var sr = new InputReader(Console.In))
//            using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
//            using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }

        private static void Main(string[] args)
        {
#if EXTENDSTACKSIZE
            var threadStart = new ThreadStart(Run);
            var thread = new Thread(threadStart, stackSize);
            thread.Start();
            thread.Join();
#else
            Run();
#endif
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            var n = sr.NextInt32();
            var numbers = sr.ReadArrayOfInt32();
            var val = 1;
            Func<int, int> func = (next) => {
                var count = 0;
                for (var i = 0; i < numbers.Length; i++) {
                    if (next * numbers[i] > 0) {
                        count++;
                    }
                }

                return count;
            };
            var mid = n % 2 == 1 ? ((n + 1) / 2) : (n / 2);
            if (func(1) >= mid) {
                sw.WriteLine(1);
                return;
            }

            if (func(-1) == mid) {
                sw.WriteLine(-1);
                return;
            }

            sw.WriteLine(0);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}


using System;
class Codeforces_round_542_A
{
  static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    string [] s = Console.ReadLine().Split(' ');
    double [] a = new double [n];
    int cntplus = 0; int cntminus = 0; int cntnol = 0;
    for(int i=0; i<n; i++)
    {
        a[i] = int.Parse(s[i]);
        if(a[i] > 0) cntplus++;
        if(a[i] < 0) cntminus++;
        if(a[i] == 0) cntnol++;
    }
    if(cntplus > n/2) Console.Write("1");
    if(cntminus > n/2) Console.Write("-1");
    if(cntnol > n/2 ) Console.Write("0");
  }
}


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

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal n = Convert.ToInt32(Console.ReadLine());
            string[] nums = Console.ReadLine().Split(' ');

            int atLeastNums = (int)Math.Ceiling(n / 2);

            int validNumsCount = 0;
            for (int i = 0; i < n; i++)
            {
                if (Convert.ToInt32(nums[i]) != 0)
                {
                    validNumsCount++;
                }
            }

            Console.WriteLine(validNumsCount >= atLeastNums ? validNumsCount : 0);
        }
    }
}


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

namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] temp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(temp[i]);
            }
            int counter1 = 0;
            int counter2 = 0;
            for(int i =0;i<N;i++)
            {
                if(a[i]<0)
                {
                    counter1++;
                }
                else if(a[i]>0)
                {
                    counter2++;
                }
            }
            if(counter1>=N/2)
            {
                Console.WriteLine(-1);
            }
            else if(counter2>=N/2)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


using System;
class Codeforces_round_542_A
{
  static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    string [] s = Console.ReadLine().Split(' ');
    double [] a = new double [n];
    int cntplus = 0; int cntminus = 0; int cntnol = 0;
    for(int i=0; i<n; i++)
    {
        a[i] = int.Parse(s[i]);
        if(a[i] > 0) cntplus++;
        if(a[i] < 0) cntminus++;
        if(a[i] == 0) cntnol++;
    }
    if(cntplus >= Math.Ceiling((double)n/2)) Console.Write("1");
    if(cntminus >= Math.Ceiling((double)n/2)) Console.Write("-1");
    if(cntnol >= Math.Ceiling((double)n/2)) Console.Write("0");
  }
}


using System;
using System.Linq;

namespace codeforces542
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Solution sol = new Solution();
            Console.WriteLine(sol.GetD(A));
        }
    }

    public class Solution
    {
        public int GetD(int[] A)
        {
            int ng = 0;
            int ps = 0;
            for (int i = 0; i < A.Length; ++i)
            {
                ng += A[i] < 0 ? 1 : 0;
                ps += A[i] > 0 ? 1 : 0;
            }

            if (ps >= A.Length / 2)
                return 1;
            if (ng >= A.Length / 2)
                return -1;
            return 0;
        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1130A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(Console.ReadLine().Split().GroupBy(x => Math.Sign(int.Parse(x))).Where(x => x.Count() * 2 >= n).Select(x => x.Key).DefaultIfEmpty(0).First());
        }
    }
}


using System;
class Codeforces_round_542_A
{
  static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    string [] s = Console.ReadLine().Split(' ');
    double [] a = new double [n];
    int cntplus = 0; int cntminus = 0; int cntnol = 0;
    for(int i=0; i<n; i++)
    {
        a[i] = int.Parse(s[i]);
        if(a[i] > 0) cntplus++;
        if(a[i] < 0) cntminus++;
        if(a[i] == 0) cntnol++;
    }
    if(cntplus >= Math.Ceiling((double)n/2)) Console.Write("1");
    else if(cntminus >= Math.Ceiling((double)n/2)) Console.Write("-1");
    else if(cntnol >= Math.Ceiling((double)n/2)) Console.Write("0");
  }
}


using System;
using System.IO;

public class Z
{
	public static int Main(string[] args)
	{
		int n = Convert.ToInt32(Console.ReadLine());
		int[] a = new int [100];string[]s=Console.ReadLine().Split(' ');for (int i = 0; i<n; ++i) a[i]=int.Parse(s[i]);
		int b=0,c=0;
		for(int i=0;i<n;++i)if(a[i]!=0)
		{
			if(a[i]>0)++b;
			if(a[i]<0)++c;
		}
		n=n%2+n/2;
		if(b>=n){Console.WriteLine("1");return 0;}
		if(c>=n){Console.WriteLine("-1");return 0;}
		Console.WriteLine("0");
		return 0;
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    readonly int dom = 998244353;
    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void solve()
    {
        int N = cin.nextint;
        var A = cin.scanint;

        int minus = 0;
        int plus = 0;
        for (int i = 0; i < N; i++)
        {
            if (A[i] > 0)
            {
                plus++;
            }
            else if(A[i] < 0)
            {
                minus++;
            }
        }

        int ans = 0;
        if (plus >= (N + 1) / 2)
        {
            ans = 1;
        }
        if (minus >= (N + 1) / 2)
        {
            ans = -1;
        }
        WriteLine(ans);
    }

}

static class Ex
{
    public static void join<T>(this IEnumerable<T> values, string sep = " ") => WriteLine(string.Join(sep, values));
    public static string concat<T>(this IEnumerable<T> values) => string.Concat(values);
    public static string reverse(this string s) { var t = s.ToCharArray(); Array.Reverse(t); return t.concat(); }

    public static int lower_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) < 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
    public static int upper_bound<T>(this IList<T> arr, T val) where T : IComparable<T>
    {
        int low = 0, high = arr.Count;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (arr[mid].CompareTo(val) <= 0) low = mid + 1;
            else high = mid;
        }
        return low;
    }
}

class Pair<T, U> : IComparable<Pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
    public T f; public U s;
    public Pair(T f, U s) { this.f = f; this.s = s; }
    public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0 ? f.CompareTo(a.f) : s.CompareTo(a.s);
    public override string ToString() => $"{f} {s}";
}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan => ReadLine().Split();
    public int[] scanint => Array.ConvertAll(scan, int.Parse);
    public long[] scanlong => Array.ConvertAll(scan, long.Parse);
    public double[] scandouble => Array.ConvertAll(scan, double.Parse);
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint => int.Parse(next);
    public long nextlong => long.Parse(next);
    public double nextdouble => double.Parse(next);
}


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

namespace ConsoleApplication23
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int pos = 0, neg = 0;
            for (int i = 0; i < n; i++)
                if (int.Parse(s[i]) > 0) pos++;
                else if (int.Parse(s[i]) < 0) neg++;

            int p = n / 2;
            if (n % 2 > 0) p++;
            if (pos >= p) Console.WriteLine(2);
            else
                if (neg >= p) Console.WriteLine(-5);
                else Console.WriteLine(0);

        }
    }
}


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

namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] temp = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] a = new int[N];
            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(temp[i]);
            }
            int counter1 = 0;
            int counter2 = 0;
            for(int i =0;i<N;i++)
            {
                if(a[i]<0)
                {
                    counter1++;
                }
                else if(a[i]>0)
                {
                    counter2++;
                }
            }
            if(counter1>=(N+N%2)/2)
            {
                Console.WriteLine(-1);
            }
            else if(counter2>=(N+N%2)/2)
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }
    }
}


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

static class UtilityMethods
{
	public static void Swap<T>(ref T a, ref T b)
	{
		T t = a;
		a = b;
		b = t;
	}

	public static int StrToInt(string s)
	{
		int number = 0;
		for (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)
			number = number * 10 + (s[i] - '0');
		return s[0] == '-' ? -number : number;
	}
	public static long StrToLong(string s)
	{
		long number = 0;
		for (int i = s[0] == '-' ? 1 : 0; i < s.Length; i++)
			number = number * 10 + (s[i] - '0');
		return s[0] == '-' ? -number : number;
	}

	public static string ReadString() => Console.ReadLine();
	public static int ReadInt() => StrToInt(ReadString());
	public static long ReadLong() => StrToLong(ReadString());
	public static double ReadDouble() => double.Parse(ReadString());

	public static string[] ReadStringArray() => ReadString().Split();
	public static int[] ReadIntArray() => Array.ConvertAll(ReadStringArray(), StrToInt);
	public static long[] ReadLongArray() => Array.ConvertAll(ReadStringArray(), StrToLong);
	public static double[] ReadDoubleArray() => ReadStringArray().Select(double.Parse).ToArray();

	public static void WriteLine(object a) => Console.WriteLine(a);
	public static void WriteLineArray<T>(string separator, T[] a, int startIndex, int count)
	{
		const int MAXLEN = 1000000;
		int len = 0, j = startIndex, lastIndex = startIndex + count;
		System.Text.StringBuilder str;
		string[] b = Array.ConvertAll(a, x => x.ToString());
		for (int i = startIndex; i < lastIndex - 1; i++)
		{
			len += b[i].Length + separator.Length;
			if (len >= MAXLEN)
			{
				str = new System.Text.StringBuilder(len);
				for (; j <= i; j++)
				{
					str.Append(b[j]);
					str.Append(separator);
				}
				Console.Write(str);
				len = 0;
			}
		}
		str = new System.Text.StringBuilder(len);
		for (; j < lastIndex - 1; j++)
		{
			str.Append(b[j]);
			str.Append(separator);
		}
		Console.Write(str);
		Console.WriteLine(b.Last());
	}
}

class Program
{
	static void Main()
	{
		int n = UtilityMethods.ReadInt();
		int[] a = UtilityMethods.ReadIntArray();
		int less = 0, eq = 0, more = 0;
		for (int i = 0; i < n; i++)
		{
			less += a[i] < 0 ? 1 : 0;
			eq += a[i] == 0 ? 1 : 0;
			more += a[i] > 0 ? 1 : 0;
		}
		if (eq + more > less && eq + less > more)
			UtilityMethods.WriteLine(0);
		else
			UtilityMethods.WriteLine(less < more ? 1 : -1);
		Console.ReadLine();
	}
}


using System;
class Codeforces_round_542_A
{
  static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    string [] s = Console.ReadLine().Split(' ');
    double [] a = new double [n];
    int cntplus = 0; int cntminus = 0; int cntnol = 0;
    for(int i=0; i<n; i++)
    {
        a[i] = int.Parse(s[i]);
        if(a[i] > 0) cntplus++;
        if(a[i] < 0) cntminus++;
        if(a[i] == 0) cntnol++;
    }
    if(cntplus >= Math.Ceiling((double)n/2)) Console.Write("1");
    else if(cntminus >= Math.Ceiling((double)n/2)) Console.Write("-1");
    else if(cntnol >= Math.Ceiling((double)n/2)) Console.Write("0");
    else Console.Write("0");
  }
}


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

namespace Be_Positive
{
    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 n = Next();
            int[] nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }
            int half = (n + 1) / 2;
            int cp = nn.Count(t => t > 0);
            if (cp >= half)
                return 1;
            int cm = nn.Count(t => t < 0);
            if (cm >= half)
                return -1;
            return 0;
        }

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


// Problem: 1130A - Be Positive
// Author: Gusztav Szmolik

using System;

class BePositive
    {
    static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        char[] delims = {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != 1)
            return -1;
        byte n;
        if (!Byte.TryParse (words[0], out n))
            return -1;
        if (n < 1 || n > 100)
            return -1;
        line = Console.ReadLine ();
        if (line == null)
            return -1;
        words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != n)
            return -1;
        byte countPos = 0;
        byte countNeg = 0;
        for (byte i = 0; i < n; i++)
            {
            short ai;
            if (!Int16.TryParse (words[i], out ai))
                return -1;
            if (ai < -1000 || ai > 1000)
                return -1;
            if (ai > 0)
                countPos++;
            else if (ai < 0)
                countNeg++;
            }
        byte halfSize = Convert.ToByte (n%2 == 0 ? n/2 : (n+1)/2);
        sbyte ans = 0;
        if (countPos >= halfSize)
            ans = 1;
        else if (countNeg >= halfSize)
            ans = -1;
        Console.WriteLine (ans);
        return 0;
        }
    }


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

namespace NetExperiment
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int mid = (int)Math.Ceiling((double)n / 2);
            if (mid <= a.Count(k => k > 0))
                Console.WriteLine(1);
            else if (mid <= a.Count(k => k < 0))
                Console.WriteLine(-1);
            else
                Console.WriteLine(0);
        }
    }
}


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

namespace Кассир
{

    class Program
    {
        public static void DFS(List<List<int>> G, int ver, bool[] visited, ref int count)
        {
            Stack<int> st = new Stack<int>();
            st.Push(ver);
            while (st.Count != 0)
            {
                int CurVer = st.Pop();
                visited[CurVer] = true;
                count++;
                for (int i = 0; i < G[CurVer].Count; i++)
                {
                    if (!visited[G[CurVer][i]])
                        st.Push(G[CurVer][i]);
                }
            }
        }
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string[] str = Console.ReadLine().Split(' ');
            int pol = 0;
            int otr = 0;
            for(int i = 0; i<str.Length; i++)
            {
                if (int.Parse(str[i]) < 0)
                    otr++;
                else if (int.Parse(str[i]) > 0)
                    pol++;
            }
            int half;
            if (str.Length % 2 == 0)
                half = str.Length / 2;
            else
            {
                half = str.Length / 2 + 1;
            }
            if(pol>=half)
                Console.WriteLine(1);
            else if(otr>=half)
                Console.WriteLine(-1);
            else
                Console.WriteLine(0);
        }
    }
}


using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int a = 0;
		int b = 0;
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
			if(A[i]>0){
				a++;
			} else if(A[i]<0){
				b++;
			}
		}
		int d = 0;
		if(a>=(N+1)/2){
			d = 1;
		} else if(b>=(N+1)/2){
			d = -1;
		}
		Console.WriteLine(d);
	}
}


using System;
using System.Collections.Generic;

public class Test
{

    private static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

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

    private static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }
    public static void Main()
    {
        int n = ReadInt();

        int target = n / 2;

        if (n % 2 != 0)
            target++;

        int[] A = ReadArray();

        int pCount = 0;
        int nCount = 0;
        int pVal = 0;
        int nVal = 0;

        for(int i = 0; i < n; i++)
        {
            if (A[i] > 0)
            {
                pCount++;
                pVal = A[i];
            }
            if (A[i] < 0)
            {
                nCount++;
                nVal = A[i];
            }
        }
        int result = 0;

        if (pCount >= target)
            result = pVal;
        else if (nCount >= target)
            result = nVal;

        Console.WriteLine(result);

    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var ar = ReadLine().Split(' ').Select(v =>int.Parse(v, InvariantCulture)).ToArray();
        var min = (num + 1) / 2;
        if (ar.Count(v => v > 0) >= min) WriteLine(1);
        else if (ar.Count(v => v < 0) >= min) WriteLine(-1);
        else WriteLine(0);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
           int n = int.Parse(Console.ReadLine());
           string[] token = Console.ReadLine().Split();

           float[] a = new float[n];

           int nn = 0,pp=0,zz=0;
           for(int i=0;i<n;i++){
             a[i] = float.Parse(token[i]);
             if(a[i]<0){
               nn++;
             }else if(a[i]>0){
               pp++;
             }else{
               zz++;
             }
           }

           int cc = n/2;

           if(n%2!=0)cc++;

           if(pp>=cc){
             Console.WriteLine(1);
           }else if(nn>=cc){
              Console.WriteLine(-1);
           }else{
              Console.WriteLine(0);
           }

        }
    }
}


using System;
using System.Linq;

namespace CSharp
{
    class _1130A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(Console.ReadLine().Split().GroupBy(x => Math.Sign(int.Parse(x))).Where(x => x.Key != 0 && x.Count() * 2 >= n).Select(x => x.Key).DefaultIfEmpty(0).First());
        }
    }
}


namespace Problem
{
    using System;
    using System.Collections.Generic;
    using System.Collections;
    class problem
    {
        static void Main()
        {
            int n = int.Parse( Console.ReadLine() );
            string[] str = Console.ReadLine().Split();
            int[] a = new int[n];
            for(int i = 0 ; i < n ; i++)
                a[i] = int.Parse( str[i] );
            int duong = 0;
            int am = 0;
            for(int i = 0 ; i < n ; i++)
            {
                if(a[i] > 0)
                    duong++;
                else if(a[i] < 0)
                    am++;
            }
            if(n % 2 == 0)
            {
                if(duong >= n / 2)
                    Console.WriteLine( 1 );
                else if(am >= n / 2)
                    Console.WriteLine( -1 );
                else
                    Console.WriteLine( 0 );
            }
            else
            {
                if(duong >= ( n / 2 + 1 ))
                    Console.WriteLine( 1 );
                else if(am >= ( n / 2 + 1 ))
                    Console.WriteLine( -1 );
                else
                    Console.WriteLine( 0 );
            }
        }
    }

}


using System;
using System.Linq;
namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            int[] mass = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int plus = mass.Count(x => x > 0);
            int zero = mass.Count(x => x == 0);
            int minus = count - plus - zero;
            int min = (int)(Math.Ceiling(count / 2.0));
            if (plus >= min) Console.WriteLine(1);
            else if (minus >= min) Console.WriteLine(-1);
            else Console.WriteLine(0);
        }
    }
}


using System;

    class Program
    {
        static void Main()
        {
            int x1,x2,y1,y2,xl,xp,yn,yv;
            int n = Convert.ToInt32(Console.ReadLine())-1;

            string[] s = Console.ReadLine().Split(' ');
                x1 = xl= Convert.ToInt32(s[0]);
                y1 = yn =Convert.ToInt32(s[1]);
                x2 = xp= Convert.ToInt32(s[2]);
                y2 = yv =Convert.ToInt32(s[3]);
                int p = (x2 - x1) * (y2 - y1);

            for (; n > 0; n--) {
                s = Console.ReadLine().Split(' ');
                x1 = Convert.ToInt32(s[0]);
                y1 = Convert.ToInt32(s[1]);
                x2 = Convert.ToInt32(s[2]);
                y2 = Convert.ToInt32(s[3]);
                if (x1 < xl) xl = x1;
                if (y1 < yn) yn = y1;
                if (x2 > xp) xp = x2;
                if (y2 > yv) yv = y2;
                p += (x2 - x1) * (y2 - y1);
            }

            if (p == (xp - xl) * (yv - yn)) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }
    }


#define Online

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

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

    partial class Program
    {

        static int n;
        static Rect[] r;
        static bool[] u;
        static int[] x = new int[31401];
        struct Rect
        {
            public int x1;
            public int y1;
            public int x2;
            public int y2;
        }

        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

            A();

#if Online
            Console.ReadLine();
#endif

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

        static void A()
        {
            n = ReadInt();
            r = new Rect[n];
            u = new bool[n];
            for (int i = 0; i < n; i++)
            {
                ReadArray(' ');
                r[i].x1 = NextInt();
                r[i].y1 = NextInt();
                r[i].x2 = NextInt();
                r[i].y2 = NextInt();
            }
            if (dfs(1, 0) || dfs(2, 0) || dfs(3, 0) || dfs(4, 0) || dfs(5, 0)) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }

        static void B()
        {
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void E()
        {

        }

        static void TestGen()
        {

        }

        static bool dfs(int z, int k)
        {
            if (k == z)
            {
                Clear();
                for (int i = 0; i < n; i++)
                {
                    if (!u[i]) continue;
                    for (int j = r[i].x1; j < r[i].x2; j++)
                    {
                        x[j] += r[i].y2 - r[i].y1;
                    }
                }

                for (int i = 0, j = 0; i < 31401; i++)
                {
                    if (x[i] > 0)
                    {
                        int val = x[i];
                        for (j = i; ; )
                        {
                            if (j < 31401 && x[j + 1] == val)
                            {
                                j++;
                            }
                            else
                            {
                                if (j == 31400) break;
                                if (x[j + 1] != 0) return false;
                                else break;

                            }
                        }
                        if (val == j - i + 1)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            for (int i = 0; i < n; i++)
            {
                if (!u[i])
                {
                    u[i] = true;
                    if (dfs(z, k + 1)) return true;
                    u[i] = false;
                }
            }
            return false;
        }

        static void Clear()
        {
            for (int i = 0; i < 31401; i++)
            {
                x[i] = 0;
            }
        }
    }

    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);
        }
    }

    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);
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        public static void Merge_Sort1<T>(T[] A, int p, int r, T[] L, T[] R, Comparison<T> comp)
        {
            int k = 1;
            while (k < r - p + 1)
            {
                int i = 0;
                while (i < r)
                {
                    int _r = Math.Min(i + 2 * k - 1, r);
                    int q = Math.Min(i + k - 1, r);
                    Merge(A, i, q, _r, L, R, comp);
                    i += 2 * k;
                }
                k <<= 1;
            }
        }

        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;
            }
        }
    }

    partial class Program
    {
        static string[] tokens;
        static int cur_token = 0;

        static void ReadArray(char sep)
        {
            cur_token = 0;
            tokens = Console.ReadLine().Split(sep);
        }

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

        static int NextInt()
        {
            return int.Parse(tokens[cur_token++]);
        }

        static long NextLong()
        {
            return long.Parse(tokens[cur_token++]);
        }

        static double NextDouble()
        {
            return double.Parse(tokens[cur_token++]);
        }

        static decimal NextDecimal()
        {
            return decimal.Parse(tokens[cur_token++]);
        }

        static string NextToken()
        {
            return tokens[cur_token++];
        }

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


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt16(Console.ReadLine());
            int ymin, ymax,x1,y1,x2,y2;
            int xmin = ymin = 32100;
            int xmax = ymax = -32100;
            long S = 0;
            string[] temp = new string[4];

            for (int i = 0; i < n; ++i)
            {
                temp=Console.ReadLine().Split(new char[]{' '});
                x1 = Convert.ToInt16(temp[0]);
                y1 = Convert.ToInt16(temp[1]);
                x2 = Convert.ToInt16(temp[2]);
                y2 = Convert.ToInt16(temp[3]);
                S += (x2 - x1) * (y2 - y1);
                if (xmin > x1) xmin = x1;
                if (xmin > x2) xmin = x2;
                if (ymin > y1) ymin = y1;
                if (ymin > y2) ymin = y2;
                if (xmax < x1) xmax = x1;
                if (xmax < x2) xmax = x2;
                if (ymax < y1) ymax = y1;
                if (ymax < y2) ymax = y2;
            }

            if (S == (xmax - xmin) * (ymax - ymin)) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}


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

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

        private static void Solve()
        {
            var n = ReadInt();
            var s = 0;
            int minX1 = int.MaxValue, maxX2 = int.MinValue, minY1 = int.MaxValue, maxY2 = int.MinValue;
            for (int i = 0; i < n; i++)
            {
                int x1, y1, x2, y2;
                Read(out x1, out y1, out x2, out y2);
                minX1 = Math.Min(minX1, x1);
                minY1 = Math.Min(minY1, y1);
                maxX2 = Math.Max(maxX2, x2);
                maxY2 = Math.Max(maxY2, y2);
                s += (x2 - x1)*(y2 - y1);
            }
            WriteLine(s==(maxX2-minX1)*(maxY2-minY1)? "YES":"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();
            }
        }

        private static int[] SortIndexs<T>(this IEnumerable<T> source) where T : IComparable
        {
            var array = source == null ? new List<T>() : source.ToList();
            var n = array.Count;
            var res = Enumerable.Range(0, n).ToArray();
            Array.Sort(res, (a, b) => array[a].CompareTo(array[b]));
            return res;
        }

        #region Reader

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

        private static void Read<T>(out T a1, out T a2)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4, out T a5, out T a6)
        {
            var input = ReadArray();
            a1 = (T)Convert.ChangeType(input[0], typeof(T));
            a2 = (T)Convert.ChangeType(input[1], typeof(T));
            a3 = (T)Convert.ChangeType(input[2], typeof(T));
            a4 = (T)Convert.ChangeType(input[3], typeof(T));
            a5 = (T)Convert.ChangeType(input[4], typeof(T));
            a6 = (T)Convert.ChangeType(input[5], typeof(T));
        }

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

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

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        private static string[] ReadArray()
        {
            var readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}