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

namespace DPL1_D
{
    class Program
    {
        const int max = 100000;
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var L = new Dictionary<int, int>();
            L[0] = int.Parse(Console.ReadLine());
            int length = 1;
            for (int i = 0; i < n-1; i++)
            {
                var t = int.Parse(Console.ReadLine());
                if (L[length - 1] < t)
                {
                    L[length++] = t;
                }
                else
                {
                    L[L.TakeWhile(s => s.Value < t).Count()] = t;
                }

            }
            Console.WriteLine(length);
        }
    }
}