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

namespace Polica
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] a = new  byte[1000];
            byte[] b = new byte[1000];
            byte[] l = new byte[1000];


            int n = Convert.ToInt32(Console.ReadLine());

            string[] str = Console.ReadLine().Split();

            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToByte(str[i]);
               
            }

            b = clone(a, n);
            
            int h = 0;
           
            for (int i = 0; i < n; i++)
            {
                for (int j = i+1; j < n; j++)
                {
                    

                    byte t = b[i];
                    b[i] = b[j];
                    b[j] = t;

                    





                    if (lepota(b, n) > h)
                    {
                       
                        l = b;
                    }

                    h = lepota(b, n);


                    b = clone(a, n);



                }





            }
           

            string s = Convert.ToString(l[0]);

            for (int k = 1; k < n; k++)
            {

                s = s + " " + Convert.ToString(l[k]);
            }

            Console.WriteLine(s);


        }
        static byte[] clone(byte[] a,int n)
        {
            byte[] b = new byte[1000];

            for (int i = 0; i <  n; i++)
            {
                b[i] = a[i];
            }
            return b;
        }
        static int lepota(byte[] a,int n)
        {
            

            int br = 1;
            bool x;

            if (a[0]<a[1])
            {
                x = true;
            }
            else
            {
                x = false;
            }
            

            for (int i = 1; i < n - 1; i++)
            {
                if (a[i] < a[i + 1])
                {
                    if (x)
                    {
                        
                            br++;
                        
                        
                    }
                    else
                    {
                        br = 1;
                    }
                    

                }
                else
                {
                    
                    if (!x)
                    {
                       
                            br++;
                        
                    }
                    else
                    {
                        br = 1;
                    }
                }
            }

            return br;
        }

       
       
    }
}