class TreeNode {
  var left: TreeNode?
  var right: TreeNode?
  var val: Int
  init(_ v: Int) {
    self.val = v
  }
  func count(_ root: TreeNode?) -> Int {
    guard let root = root else { return 0 }
    return 1 + count(root.left) + count(root.right)
  }
  func find(_ root: TreeNode?, _ v: Int) -> TreeNode? {
    guard let root = root else {
      return nil
    }
    if root.val >= v {
      return find(root.left, v)
    } else {
      return find(root.right, v) ?? root
    }
  }
  func remove(_ root: TreeNode?, _ v: Int) -> TreeNode? {
    guard let root = root else {
      return nil
    }
    if root.val != v {
      if v < root.val {
        root.left = remove(root.left, v)
      } else {
        root.right = remove(root.right, v)
      }
      return root
    } else {
      if root.left == nil && root.right == nil {
        return nil
      } else if root.right != nil {
        let target = successor(root.right)!
       	let tmp = target.val
        target.val = root.val
        root.val = tmp
        root.right = remove(root.right, v)
        return root
      } else {
        let target = predecessor(root.left)!
       	let tmp = target.val
        target.val = root.val
        root.val = tmp
        root.left = remove(root.left, v)
        return root
      }
    }
  }
  func insert(_ root: TreeNode?, _ v: Int) -> TreeNode? {
    guard let root = root else {
      return TreeNode(v)
    }
    if v <= root.val  {
      root.left = insert(root.left, v)
    } else {
      root.right = insert(root.right, v)
    }
    return root
  }
  private func predecessor(_ root: TreeNode?) -> TreeNode? {
    var p = root
    while p?.right != nil {
      p = p?.right
    }
    return p
  }
  private func successor(_ root: TreeNode?) -> TreeNode? {
    var p = root
    while p?.left != nil {
      p = p?.left
    }
    return p
  }
}

let n = Int(readLine()!)!

var a: [Int] = .init(repeating: 0, count: n)

for i in 0..<n {
  a[i] = Int(readLine()!)!
}

var bst = TreeNode(a[0])
for i in 1..<a.count {
  let ai = a[i]
  if let found = bst.find(bst, ai) {
    bst = bst.remove(bst, found.val)!
  }
  bst = bst.insert(bst, ai)!
}
print(bst.count(bst))