function half(a, b, i){
	if(a.length == 1) return a[0][1] <= b ? a[0][0] : null
	var front = a.slice(0,a.length/2)
	var back = a.slice(a.length/2)
  	if(front[front.length-1][1] > b){
      return half(front, b) 
    }else{
      if(back[0][1] > b){
        return front[front.length-1][0]
      }else{
        return half(back, b)
      } 
    }
}

function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const As = input.slice(1).map(x => parseInt(x))
	var colors = new Map()
	colors.set(0, As[0])
	var colorId = 0
	for(i=1; i < N; i++){
		var colorarray = [...colors.entries()]
		var nowColorId = half(colorarray, As[i], i)
		if(nowColorId == null){
			colorId++
			colors.set(colorId,As[i])
		}else{
			colors.set(nowColorId,As[i])
		}
		colors = new Map([...colors.entries()].sort((a,b) => a[1] - b[1]));
	}
	console.log(colorId+1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));