Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sort execution, edges appear as described in the following algorithm (pseudocode). 
    
    
      
    procedure bubbleSortGraph()  
        build a graph G with n vertices and 0 edges  
        repeat  
            swapped = false  
            for i = 1 to n - 1 inclusive do:  
                if a[i] > a[i + 1] then  
                    add an undirected edge in G between a[i] and a[i + 1]  
                    swap( a[i], a[i + 1] )  
                    swapped = true  
                end if  
            end for  
        until not swapped   
        /* repeat the algorithm as long as swapped value is true. */   
    end procedure  
    

For a graph, an independent set is a set of vertices in a graph, no two of which are adjacent (so there are no edges between vertices of an independent set). A maximum independent set is an independent set which has maximum cardinality. Given the permutation, find the size of the maximum independent set of graph G, if we use such permutation as the premutation a in procedure bubbleSortGraph.

Input

The first line of the input contains an integer n (2 ≤ n ≤ 105). The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n).

Output

Output a single integer — the answer to the problem. 

Examples

Input

3
3 1 2


Output

2

Note

Consider the first example. Bubble sort swaps elements 3 and 1. We add edge (1, 3). Permutation is now [1, 3, 2]. Then bubble sort swaps elements 3 and 2. We add edge (2, 3). Permutation is now sorted. We have a graph with 3 vertices and 2 edges (1, 3) and (2, 3). Its maximal independent set is [1, 2].
100
36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23 95 32 55 47
 5
4 2 1 3 5
 10
1 9 8 10 2 3 4 6 5 7
 50
12 24 42 43 36 3 40 29 7 34 10 13 28 9 35 23 25 21 19 4 20 18 11 38 41 48 6 46 33 17 31 37 2 30 32 44 45 5 47 49 16 15 50 27 26 14 39 22 1 8

16
 3
 6
 13

	import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.TreeMap;
		public class Main implements Runnable
		{
			static final long MOD = 1000000007L;
			static final long MOD2 = 1000000009L;
			static class InputReader
			{
				private InputStream stream;
				private byte[] buf = new byte[1024];
				private int curChar;
				private int numChars;
				private SpaceCharFilter filter;
				private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		 
				public InputReader(InputStream stream)
				{
					this.stream = stream;
				}
				
				public int read()
				{
					if (numChars==-1) 
						throw new InputMismatchException();
					
					if (curChar >= numChars)
					{
						curChar = 0;
						try 
						{
							numChars = stream.read(buf);
						}
						catch (IOException e)
						{
							throw new InputMismatchException();
						}
						
						if(numChars <= 0)				
							return -1;
					}
					return buf[curChar++];
				}
			 
				public String nextLine()
				{
					String str = "";
		            try
		            {
		                str = br.readLine();
		            }
		            catch (IOException e)
		            {
		                e.printStackTrace();
		            }
		            return str;
				}
				public int nextInt()
				{
					int c = read();
					
					while(isSpaceChar(c)) 
						c = read();
					
					int sgn = 1;
					
					if (c == '-') 
					{
						sgn = -1;
						c = read();
					}
					
					int res = 0;
					do 
					{
						if(c<'0'||c>'9') 
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c)); 
					
					return res * sgn;
				}
				
				public long nextLong() 
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-') 
					{
						sgn = -1;
						c = read();
					}
					long res = 0;
					
					do 
					{
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					while (!isSpaceChar(c));
						return res * sgn;
				}
				
				public double nextDouble() 
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					int sgn = 1;
					if (c == '-') 
					{
						sgn = -1;
						c = read();
					}
					double res = 0;
					while (!isSpaceChar(c) && c != '.') 
					{
						if (c == 'e' || c == 'E')
							return res * Math.pow(10, nextInt());
						if (c < '0' || c > '9')
							throw new InputMismatchException();
						res *= 10;
						res += c - '0';
						c = read();
					}
					if (c == '.') 
					{
						c = read();
						double m = 1;
						while (!isSpaceChar(c)) 
						{
							if (c == 'e' || c == 'E')
								return res * Math.pow(10, nextInt());
							if (c < '0' || c > '9')
								throw new InputMismatchException();
							m /= 10;
							res += (c - '0') * m;
							c = read();
						}
					}
					return res * sgn;
				}
				
				public String readString() 
				{
					int c = read();
					while (isSpaceChar(c))
						c = read();
					StringBuilder res = new StringBuilder();
					do 
					{
						res.appendCodePoint(c);
						c = read();
					} 
					while (!isSpaceChar(c));
					
					return res.toString();
				}
			 
				public boolean isSpaceChar(int c) 
				{
					if (filter != null)
						return filter.isSpaceChar(c);
					return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
				}
			 
				public String next() 
				{
					return readString();
				}
				
				public interface SpaceCharFilter 
				{
					public boolean isSpaceChar(int ch);
				}
			}
		 	
			public static void main(String args[]) throws Exception
			{
				new Thread(null, new Main(),"Main",1<<26).start();
			}
			int MAXN = 100001;
			ArrayList<Integer> adj[];
			int V;
			public void run() 
			{
				InputReader sc= new InputReader(System.in);
				PrintWriter w= new PrintWriter(System.out);
				int n = sc.nextInt();
				int[] arr = new int[n];
				for(int i = 0;i < n;i++) {
					arr[i] = sc.nextInt();
				}
				int[] ar = new int[n];
				int length = 0;
				for(int i = 0;i < n;i++) {
					if(i == 0) {
						ar[0] = i;
						length = 1;
						continue;
					}
					int ind = bsearch(ar, arr[i], arr, length);
					ar[ind] = i;
					if(length + 1 == ind) {
						length++;
					}
				}
				w.println(length);
				w.close();
			}
			int bsearch(int[] ar,int val,int[] arr,int length){
				int l = 0;
				int r = length-1;
				int ans = -1;
				while(l <= r) {
					int mid = (l + r)/2;
					if(arr[ar[mid]] > val) {
						ans = mid;
						r = mid - 1;
					}else {
						l = mid + 1;
					}
				}
				if(ans == -1) {
					return length+1;
				}
				return ans;
			}
			boolean[] visited;
			void dfs(int a) {
				visited[a] = true;
				Iterator<Integer> it = adj[a].iterator();
				while(it.hasNext()) {
					int x = it.next();
					if(!visited[x]) {
						dfs(x);
					}
				}
			}
			int cnt=  0;
			void dfsUtil(int a,boolean[] visit) {
				visit[a] = true;
				Iterator<Integer> it = adj[a].iterator();
				while(it.hasNext()) {
					int x = it.next();
					if(!visit[x]) {
						cnt++;
						dfsUtil(x,visit);
					}
				}
			}
			
			String reverse(String a) {
				String navi = "";
				for(int i = a.length()-1;i >= 0;i--) {
					navi += a.charAt(i);
				}
				return navi;
			}
			static boolean isPrime(long n)
		    {
		        // Corner cases
		        if (n <= 1) return false;
		        if (n <= 3) return true;
		     
		        // This is checked so that we can skip 
		        // middle five numbers in below loop
		        if (n % 2 == 0 || n % 3 == 0) return false;
		     
		        for (int i = 5; i * i <= n; i = i + 6)
		            if (n % i == 0 || n % (i + 2) == 0)
		            return false;
		     
		        return true;
		    }
		 
			long count = 0;
			long[][] dist;
			void flydwarShall(int k,int size) {
				for(int i = 0;i < size;i++) {
					for(int j = 0;j < size;j++) {
						if(dist[i][j] > dist[i][k] + dist[k][j]) {
							dist[i][j] = dist[i][k] + dist[k][j];
						}
					}
				}
			}
			Pair[] segTree;
			int[] arr;
			void build(int l,int r,int pos) {
				if(l == r) {
					segTree[pos] = new Pair(1,1,1,arr[l],arr[l],true);
					return;
				}
				int mid = (l + r) >> 1;
				build(l,mid,2*pos+1);
				build(mid+1, r, 2*pos+2);
				segTree[pos] = merge(segTree[2*pos+1], segTree[2*pos+2]);
			}
			Pair merge(Pair p1,Pair p2) {
				if(p1.val1 == 0) {
					return p2;
				}else if(p2.val1 == 0) {
					return p1;
				}
				Pair navi = new Pair();
				navi.val1 = p1.val1;
				navi.val2 = p2.val2;
				if(p1.val2 == p2.val1) {
					navi.max = Math.max(p1.max,p2.max);
					navi.first = p1.first;
					navi.second = p2.second;
					navi.whole = false;
				}else {
					navi.max = Math.max(p1.max,Math.max(p2.max,p1.second + p2.first));
					if(p1.whole && p2.whole) {
						navi.first = p1.first + p2.first;
						navi.second = p1.first + p2.first;
						navi.whole = true;
					}else if(p1.whole) {
						navi.first = p1.first + p2.first;
						navi.second = p2.second;
						navi.whole = false;
					}else if(p2.whole) {
						navi.first = p1.first;
						navi.second = p1.second + p2.first;
						navi.whole = false;
					}else {
						navi.first = p1.first;
						navi.second = p2.second;
						navi.whole = false;
					}
				}
				return navi;
			}
			Pair query(int pos, int l, int r, int start, int end)
			{
			    if(end < l || r < start)
			    {
			        return new Pair(0,0,0,0,0,false);
			    }
			    if(start <= l && r <= end)
			    {
			        // range represented by a node is completely inside the given range
			        return segTree[pos];
			    }
			    // range represented by a node is partially inside and partially outside the given range
			    int mid = (l + r) / 2;
			    Pair p1 = query(2*pos + 1, l, mid, start, end);
			    Pair p2 = query(2*pos+2, mid+1, r, start, end);
			    return merge(p1, p2);
			}
			int bsearch(Integer[] arr,int l,int r,int val) {
				int ind = -1;
				while(l <= r) {
					int mid = (l + r)/2;
					if(arr[mid] <= val) {
						l = mid + 1;
						ind = mid;
					}else {
						r = mid - 1;
					}
				}
				return ind;
			}
			
			
			long modExpo(long a,long pow,long mod) {
				long res = 1;
				while(pow > 0) {
					if(pow % 2 == 1) {
						res = (res * a) % mod;
					}
					pow = pow/2;
					a = (a * a) % mod;
				}
				return res;
			}
			  static long modInverse(long a, long m)
			    {
			        
			       
			            // If a and m are relatively prime, then modulo inverse
			            // is a^(m-2) mode m
			         
			                        return        power(a, m - 2, m);
			        
			    }
			     
			    // To compute x^y under modulo m
			// Iterative Java program to 
			// compute modular power
			
			    static long power(long x, long y,long p)
			    {
			        // Initialize result
			        long res = 1;     
			        
			        // Update x if it is more  
			        // than or equal to p
			        x = x % p; 
			     
			        while (y > 0)
			        {
			            // If y is odd, multiply x
			            // with result
			            if((y & 1)==1)
			                res = (res * x) % p;
			     
			            // y must be even now
			            // y = y / 2
			            y = y >> 1; 
			            x = (x * x) % p; 
			        }
			        return res;
			    }
			static class Temp implements Comparable<Temp>{
				String a;
				int b;
				Temp(String a,int b){
					this.a = a;
					this.b = b;
				}
				@Override
				public int compareTo(Temp t){
					return Integer.compare(t.b,this.b);
				}
			}
			static class Pair implements Comparable<Pair>{
				int first;
				int max;
				int second;
				int val1;
				int val2;
				boolean whole;
				
				Pair (int a,int b,int c,int val1,int val2,boolean whole){
					this.first = a;
					this.max = b;
					this.second = c;
					this.val1= val1;
					this.val2 = val2;
					this.whole = whole;
				}
				Pair(){
					
				}
				public boolean equals(Object o)
				{
					Pair p = (Pair)o;
					return (p.first==first && p.max==max) || (p.first == max && p.first == max);
				}
				public int hashCode()
				{
					return new Long(first).hashCode()*31 + new Long(max).hashCode();
				}
				public int compareTo(Pair p){
					return Long.compare(p.first,this.first);
				}
			}
		
		}