Problem:
Score : 200 points

Problem Statement

An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi.

Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Constraints

1 ≤ N ≤ 100

1 ≤ d_i ≤ 100

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
d_1
:
d_N

Output

Print the maximum number of layers in a kagami mochi that can be made.

Sample Input 1

4
10
8
8
6

Sample Output 1

3

If we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.

Sample Input 2

3
15
15
15

Sample Output 2

1

When all the mochi have the same diameter, we can only have a 1-layered kagami mochi.

Sample Input 3

7
50
30
50
100
50
80
30

Sample Output 3

4

Solution in Scala (2.11.7) (judge verdict: Accepted)

import java.util.Scanner

object Main {
  type T = Int

  sealed abstract class Node

  case class Branch(value: T, priority: Double, left: Node, right: Node) extends Node

  case object Leaf extends Node

  class MySet(val root: Node) {
    def insert(value: T): (MySet, Boolean) = if (contains(value)) {
        (new MySet(root), false)
      } else {
      val (left, right) = split_less(root, value)
      val single = Branch(value, math.random, Leaf, Leaf)
      (new MySet(merge(merge(left, single), right)), false)
    }

    def erase(value: T): (MySet, Boolean) = if (contains(value)) {
        val (left, tmp) = split_less(root, value)
        val (_, right) = split_leq(tmp, value)
        (new MySet(merge(left, right)), true)
      } else {
      (new MySet(root), false)
    }

    def contains(value: T): Boolean = find(root, value)

    def toList(): List[T] = makeList(root)
  }

  def merge(left: Node, right: Node): Node = (left, right) match {
    case (Leaf, r) => r
    case (l, Leaf) => l
    case (l: Branch, r: Branch) => {
      if (l.priority > r.priority) {
        Branch(l.value, l.priority, l.left, merge(l.right, right))
      } else {
        Branch(r.value, r.priority, merge(left, r.left), r.right)
      }
    }
  }

  def split_less(node: Node, value: T): (Node, Node) = node match {
    case Leaf => (Leaf, Leaf)
    case Branch(x, p, l, r) => {
      if (x < value) {
        val (rl, rr) = split_less(r, value)
        (Branch(x, p, l, rl), rr)
      } else {
        val (ll, lr) = split_less(l, value)
        (ll, Branch(x, p, lr, r))
      }
    }
  }

  def split_leq(node: Node, value: T): (Node, Node) = node match {
    case Leaf => (Leaf, Leaf)
    case Branch(x, p, l, r) => {
      if (x <= value) {
        val (rl, rr) = split_leq(r, value)
        (Branch(x, p, l, rl), rr)
      } else {
        val (ll, lr) = split_leq(l, value)
        (ll, Branch(x, p, lr, r))
      }
    }
  }

  def find(node: Node, value: T): Boolean = node match {
    case Leaf => false
    case Branch(x, _, l, r) => {
      if (value < x) find(l, value)
      else if (x == value) true
      else find(r, value)
    }
  }

  def makeList(tree: Node): List[T] = tree match {
    case Leaf => Nil
    case Branch(x, _, l, r) => makeList(l) ++ List(x) ++ makeList(r)
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt

    var s = new MySet(Leaf)
    for (_ <- 0 until n) s = s.insert(sc.nextInt)._1
    val ls = s.toList()
    // println(ls)
    println(ls.length)
  }
}