fun readInt () = valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn) fun quicksort [] = [] | quicksort (h::tl) = let val (s, b) = List.foldl (fn (x, (small, big)) => if x <= h then (x::small, big) else (small, x::big)) ([], []) tl in (quicksort s) @ [h] @ (quicksort b) end fun isSatisfy l = let fun isSatisfyAux _ nil = true | isSatisfyAux _ [_] = true | isSatisfyAux diff (h1::h2::tl) = if h2 - h1 = diff then isSatisfyAux diff (h2::tl) else false val (h1::h2::tl) = quicksort l in if h2 - h1 = 0 then false else isSatisfyAux (h2 - h1) (h2::tl) end val () = let val n = readInt () val x_s = List.tabulate (n, fn _ => readInt ()) val ans = if isSatisfy x_s then "YES" else "NO" in print (ans ^ "\n") end